Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

API Call Hygiene/Efficiency question

Matthew Schrader
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
August 17, 2024

Hello, recently I have been in a collaboration at work to create a Py script that calls the JIRA API to do some automation.

A short summary of the script:

  • Retrieves all open tickets assigned to a user.
  • Creates a directory of the JIRA tickets as folders on their local desktop. Names each folder after the ticket number and project title.
  • Creates subfolders based on ticket conditionals within each ticket folder for storing related project assets.
  • Generates a .md file containing the ticket's project details in each folder.
  • Copies specific template files into certain subfolders based on ticket conditionals.

This script combined with Windows scheduler could essentially mean that I never have to manually create a folder or perhaps even file for work again, so I've been excited.

One thing however, I wanted to triple check that doing something like this would just involve ONE API call only. Our IT admin expressed some valid concern about this script stress testing our server if too many calls are made by too many people. 

The code can be found here if a look is desired:

https://pastebin.com/Gps3SvhR

1 answer

2 votes
Darryl Lee
Community Champion
August 17, 2024

Hi @Matthew Schrader - so looking at your code, I only can only see one API call:

 issues = jira.search_issues(f'assignee={username} AND status = "Open"')

Jira's API doesn't spawn or require multiple calls unless your users have more than 100 open issues assigned to them. In that case, you're going to have to implement pagination, which will require more API calls. One for every 100 issues. (You will need to set the maxResults=100.)

One thing that would recommend is using the fields parameter to ensure that you are only pulling fields you need: ["reporter", "summary", "description", "created"]

This should optimize the call and make it as efficient as possible:

WARNING: I'm not very good at Python :-} so you might need to read the docs and try a few things to get the fields bit to work. They say you can also use a comma-separated string: 

  • fields (Optional[Union[str, List[str]]]) – comma-separated string or list of issue fields to include in the results. Default is to include all fields.

Suggest an answer

Log in or Sign up to answer