How to retrieve all project versions from Jira REST API with Python requests

I’m working on migrating my Python code from using the JIRA library to making direct HTTP requests with the requests module. Previously I was able to get all project versions using JIRA.project_versions(project_id) but now I need to accomplish the same thing with REST API calls.

I already have a working example for fetching issue counts:

api_response = requests.get(
    "https://company.atlassian.net/rest/api/2/search",
    headers={"Accept": "application/json"},
    params={
        'jql': 'project=TEST_PROJECT',
        'startAt': 0,
        'maxResults': 0
    },
    auth=HTTPBasicAuth(username, api_token)
)

This works fine for getting issue data with pagination, but I’m struggling to find the correct endpoint and parameters to fetch all versions/releases for a specific project. What’s the proper way to get project versions using the Jira REST API?

The endpoint you want is /rest/api/2/project/{projectKey}/versions. I hit this same problem last year when ditching the JIRA library. Here’s what worked:

api_response = requests.get(
    "https://company.atlassian.net/rest/api/2/project/TEST_PROJECT/versions",
    headers={"Accept": "application/json"},
    auth=HTTPBasicAuth(username, api_token)
)
versions = api_response.json()

This grabs all versions for the project - no pagination needed since projects don’t usually have thousands of versions. You’ll get back version details like name, description, release date, and archived status. You can swap the project key for project ID in the URL if that’s what you’ve got. Don’t forget to check response status codes for errors.

Just hit /rest/api/2/project/{projectIdOrKey}/versions - swap {projectIdOrKey} for your project key or ID. Way better than that old JIRA library. Quick heads up though - the response comes back as a straight JSON array, not wrapped in search results like you’d get with issues.

Hit this same migration issue 6 months ago. The /rest/api/2/project/{projectKey}/versions endpoint works great, but heads up - versions come back in whatever random order Jira stores them, not sorted by release date or name. You’ll need to sort the response yourself if order matters. Also, archived versions show up by default, so filter those out if you don’t want them. The JSON’s straightforward - each version has name, released, archived, and releaseDate fields.