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.
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
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.