How to sort JIRA issues by last modified date using Python REST API

I’m working with the JIRA Python library to fetch issues from my project board. Right now my script pulls the most recent 50 tickets but they come sorted by creation date instead of modification date.

I need to change the sorting so it shows the 50 most recently updated issues first. Here’s what I have so far:

connection_settings = {'server': "https://mycompany.atlassian.net"}
jira_client = JIRA(options=connection_settings, basic_auth=(username, api_key))

for ticket in jira_client.search_issues(jql_str=f"project = PROJ"):
    ticket_id = ticket.key
    field_data = ticket.raw['fields']
    creation_date = field_data['created']
    modification_date = field_data['updated']

What JQL query or parameter should I use to get issues ordered by their last update time?

quick tip - if u’re getting weird results, check ur timezone handling. jira stores timestamps in utc but shows em in your local timezone, so sorting can look wrong if u don’t account for this.

Manual JQL sorting works, but you’ll hit walls fast when your data gets messy or you need it integrated elsewhere.

Hit this same issue last year building dashboards. Yeah, ORDER BY works fine, but what about combining data with other tools? Or auto-generating reports from these updates?

Better to automate the whole thing. Build a workflow that pulls JIRA data on schedule, sorts it how you want, and feeds it straight to your reports or database.

You can set up monitors for JIRA updates that auto-sort and filter results, then push everything where it needs to go. No more manual scripts or API rate limit headaches during peak times.

Seen teams cut hours every week by automating JIRA flows instead of writing custom scripts for everything.

https://latenode.com has solid automation options - way more scalable than doing this manually.

The default search_issues method caps at 1000 results, but for large projects you’ll want to use the expand parameter. I found that adding expand='changelog' to your search_issues call gives you way better update history data. This is huge when you need to filter specific updates or track who made the last real change. The changelog expansion shows exactly which fields got modified in each update - so you can tell the difference between status changes, new comments, and actual field updates. Just heads up: expanded results are slower and eat more memory, so weigh that against your performance needs.

You can use the maxResults parameter in your search_issues call to limit results directly instead of dealing with pagination. Try jira_client.search_issues(jql_str="project = PROJ order by updated desc", maxResults=50) - it’ll get you exactly what you want. I’ve found this way more reliable than handling pagination manually, especially with bigger projects where you might hit JIRA’s search limits. The updated field in JQL matches the modification_date you’re already pulling from raw fields, so your current code should work fine.

just add order by updated desc in your jql. it should look like f"project = PROJ order by updated desc" - that way you get the latest modified issues first instead of those created.

The JQL ordering syntax is pretty straightforward, but there’s a gotcha that’ll bite you. When I first built this same thing, I found out JIRA’s REST API behaves differently depending on your instance setup. Some orgs have custom fields that mess with the updated timestamp, so try order by updated desc, created desc as backup sorting. Also heads up - the updated field catches manual edits AND automated stuff like workflow transitions. If you only want manual changes, use order by updatedDate desc instead. Small difference but it matters depending on your use case and how your team runs workflows.