Jira query returns fewer issues in Python than JQL search for completed tasks

I’m facing an issue where I can’t retrieve all completed tasks from a Jira project using the Python client. In the JIRA web interface, a JQL query shows there are 3096 tasks marked as Done or Closed. However, when I run my Python code, it only gets about 50 tasks.

#!/usr/bin/python
import jira
from jira import JIRA

server_options = {'server': 'http://jira.example.com'}
jira_client = JIRA(server_options, basic_auth=('admin', 'admin'))
projects = jira_client.projects()

for proj in projects:
    issue_list = jira_client.search_issues('project=PROJECT')

for issue in issue_list:
    if str(issue.fields.status) == 'Done' or str(issue.fields.status) == 'Closed':
        print(issue)

I only retrieve around 50 issues, even though the JQL query indicates more than 3000 with Done or Closed status. Is there a possibility of hitting a limit or something similar?

yep, sounds like u hit the limit! the search_issues() func defaults to 50. try setting maxResults to False to get all results or set it to 5000 for more. should do the trick!

Yeah, that’s definitely a pagination issue. Hit the same problem pulling data from our Jira instance last year. Use the startAt parameter with maxResults to batch through everything. I set maxResults=1000 and loop with startAt increments until I get fewer results than the batch size. Setting maxResults=False will timeout on huge datasets, so batching gives you way better control and error handling when you’re dealing with thousands of records.

Yeah, that’s the pagination limit hitting you. JIRA’s Python library caps results at 50 by default so it doesn’t hammer the server. You’re filtering status in Python after getting the results, but you should build that filter right into your JQL query and bump up maxResults. Try jira_client.search_issues('project=PROJECT AND status in (Done, Closed)', maxResults=False). Way more efficient since the server does the filtering, and you’ll get all results without that 50-item cap.