Get Sprints API need to sort by Sprint Id so that I can just fetch the latest N sprints, but not all

When I developed a forge app against large dataset, the Rest API call to get all sprints will trigger rate limit. I want to get the latest 20 sprints, instead of all sprints. Any Atlassian developers can take a look? Thanks.

The Get a sprint endpoint returns only the sprints you ask for, not all sprints:

Get sprint

GET /rest/agile/1.0/sprint/{sprintId}
Returns the sprint for a given sprint ID.

Are you sure you’re not confusing it with the Get all sprints endpoint?

Also, what do you mean by ‘latest’ sprint? Sprints can have only one of three possible states…future, active or closed. Searching for sprints based on their states is already supported by the Get all sprints endpoint via the state parameter:

Filters results to sprints in specified states. Valid values: future, active, closed. You can define multiple states separated by commas, e.g. state=active,closed

sorry for the typo and the correct one is:

What I want is to fetch the latest 20 sprints using API (latest means the sprints ordered by sprint id desc)

As you can see from reading the documentation for the Get all sprints endpoint, it doesn’t have any functionality to limit or sort the search results based on your specific requirements, so you will have to do that in your app’s code.

I suggest that you start by making the decision as to whether you want to get only the sprints with the status future or active as being the ‘latest’, or whether you want only the closed sprints, then at least the set returned will be a bit smaller instead of getting them all, which leaves only the coding task of sorting the sprints by their ID and discarding all but the last 20.

Also, I think you have missed an important concept, which is that the ID of a sprint is just a unique, sequentially numbered identifier of the object that is assigned at the time of creation, but it has no correlation to the name of the sprint or the start date, which are the true indicators of it being the ‘latest’ based on ranking / ordering as viewed on a board.

Have fun with the problem.

Thanks @sunnyape,

I know the sprint id is automatically incremented at jira system level. Considering from the business perspective, I would like to get the latest 20 sprints for a specific board in a specific project. If the board has just 5 sprints related, then the 5 sprints should return to the frontend.

The challenge I meet with is to deal with large dataset of sprints in a specific project/board. So that’s the reason why I need the Rest API extending to support order by sprint id in a specific board.

There is a ticket to follow up this requirement: [JRACLOUD-80882] Unable of obtain latest sptints using endpoint /rest/agile/1.0/board/{boardId}/sprint - Create and track feature requests for Atlassian products.

if you also need it, please vote and comment on it

Could you please change the backend to return the sprints ordered by sprint ids from biggest to smallest? We don’t need to change API interface, which is the best way to save time. Please consider this suggestion.
Thanks @dmorrow @tpettersen

Hi @sunnyape

The response of Get all sprints in the API doc has the total number of sprints returned, but in fact, I tried and no this total value returned. If I can get the total number, e.g. 895, then I will invoke the API by passing the startAt = 895 - 50 so as to get the latest 50 sprints in a specific board.

Please take a look. Thanks.

Hello @YY1

Yep. I can confirm that the Get all sprints endpoint does not returning the total object that the documentation says should be there.

Please take a look at JSWCLOUD-23039. Thanks.

1 Like

Hello everyone, I’m having an issue, I made a post but no one has checked it out. I would appreciate any assistance I can get. Audio Recording in Forge

Hello @osarenrenisorae

It’s considered to be very, very poor etiquette to hijack some else’s question on a totally unrelated topic just because you’re not getting the attention you want elsewhere. Please don’t do that on this particular thread again.

1 Like

I’m very sorry @sunnyape. I was getting frustrated as no one responded to my post for 4 days. I wont do this again.