Forums

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

JIRA Rest API to get Story Points Committed and Completed in a Sprint

Ian Rees
Contributor
November 6, 2020

Does anybody know how to get the Story Points Committed and Completed in a Sprint from the JIRA REST API - the same as is shown in the Velocity charts

3 answers

1 accepted

0 votes
Answer accepted
Bill Sheboy
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 6, 2020

Hi @Ian Rees 

I believe the velocity report gets the data, just-in-time, for the issues assigned to the sprint and rolls up the data.  Which is why history is subjective on some JIRA scrum reports because users can alter the values of sprint, story points, etc. and the changes are only reflected on the sprint report, not things like the velocity chart.

To use the REST API to do the same you would get the issues when the sprint starts to roll-up the values, get the issues again when the sprint completes to compare/contrast.

Alternatively, you could use automation rules to do the same, and set entity properties in the sprint to capture the committed, completed, changed, etc.

Best regards,

Bill

Ian Rees
Contributor
November 8, 2020

Thanks Bill, I need to do this from the REST API.  I can see a REST call to get the issues for a Sprint but this would mean getting the issues for a Sprint on the date it started and then the issues on the date it completed and I can't see a way of doing that.  

Bill Sheboy
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 9, 2020

I believe you are correct: you would need information about the sprint externally from Jira to know when to make the REST API calls, and then perhaps schedule them. 

Could you first use the REST API to get the sprint information, and then use that to set the scheduled calls for after start and after completed?

https://docs.atlassian.com/jira-software/REST/7.3.1/#agile/1.0/board/{boardId}/sprint-getAllSprints

1 vote
Tom Rouillard
Contributor
September 6, 2024

I just added this answer to a similar question. Adding here in case someone else finds this question separately.

Ok, I've been working my way through this same issue for some time now and reviewed numerous questions / answers on these boards. Here's what I found today while reviewing the console queries in Chrome when requesting the velocity chart for a specific board. I got to this answer from a comment on another question where this API was exposed, but the returned data was limited to the past 7 sprints. Instead, this one is limited to 120 sprints, which should be sufficient for most purposes.

The trick is to add a date range to the query and changing the "velocity" endpoint to "velocity.json".

When I ran the following API request through my Jira system in postman, I got back 18 sprints with sprint ids, start / end dates, commitment & completion points. 

https:://<your-jira-domain.com>/rest/greenhopper/1.0/rapid/charts/velocity.json?rapidViewId=10986&sprintsFinishedBefore=2024-09-07T04%3A59%3A59.999Z&sprintsFinishedAfter=2023-12-25T05%3A00%3A00.000Z

Run this in postman with your auth token and you will get back JSON with Sprint details in an array of sprints, like this ...

{
"sprints": [
{
"id": 12345,
"sequence": 12345,
"rapidViewId": 54321,
"name": "This is an Example Sprint Name",
"state": "CLOSED",
"goal": "",
"autoStartStop": false,
"synced": false,
"startDate": "21/Aug/24 9:20 AM",
"endDate": "04/Sep/24 9:20 AM",
"activatedDate": "21/Aug/24 2:12 PM",
"completeDate": "04/Sep/24 1:07 PM",
"canUpdateSprint": true,
"canStartStopSprint": true,
"canUpdateDates": true,
"remoteLinks": [],
"daysRemaining": 0
},
{ <more sprints> }
],
I'm not a fan of the date formatting in this response, but if this is the price to pay for getting all the data I need in a single call, I can manage reformatting the dates.
In the same JSON response, you will get velocity information that follows this format where estimated->value = your commitment and completed->value = what you finished (in points).
You'll have one velocity stat entry for every sprint entry in the list above. You'll need the sprint id from the first list to match with the velocity information in the second list. This is demonstrated below by the "12345" entry, which matches the sprint id in the example JSON above.
Also, note that the velocity stats do not come in as an array. Don't ask me why, I'm just delivering the news.
  "velocityStatEntries": {
"12345": {
"estimated": {
"value": 78.0,
"text": "78.0"
},
"completed": {
"value": 80.0,
"text": "80.0"
}
},
{ <more sprints> }
}
Bill Sheboy
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 8, 2024

Hi @Tom Rouillard 

FYI those old Greenhopper APIs are likely deprecated and unsupported.  Please consider other solution approaches to avoid surprises.

Kind regards,
Bill

Tom Rouillard
Contributor
September 9, 2024 edited

@Bill Sheboy , I'll keep an eye on our Jira version just in case the Greenhopper API gets dropped. The thing is, though, that I didn't randomly use it, I found that my Jira instance was pulling this API for its own velocity chart report. I looked through all the network resources in my browser console before finding and using this one.

I will also note that in order to use this API, I do have to pass an atlassian.xsrf.token cookie that appears to never change. I didn't realize that Postman was automatically receiving and passing this to my server. In any case, it works if you add that to the header of your request along with your normal auth token.

My use case is that I need to get a monthly report for multiple scrum boards covering a specific product ... so four sprints per month. I need the starting sprint points value (commitment) and the ending points value (completion) so that I can calculate a completion percentage. This is one of many automated reports I'm pulling using Jira APIs, GitLab APIs, etc.

While I can get the start and end dates from the normal Jira rest API, and I can use that to craft a JQL query to get all the work done in a sprint (being careful to set resolutiondate constraints), I couldn't see a way to get the sprint's starting point value.

I really do not want to have to manually enter start / end values for each sprint because that's error prone and basically creating a user interface where instead the data should be accessible. So, a report that used to take me several minutes to pull together by visiting a very slow velocity report for each of my teams, then manually entering data into excel, now takes upwards of 12 seconds and even less when I cache the JSON results from Jira.

Running this automatically, I was able to figure out that some of my previous reports were wrong due to human error (me). Anyway, I'll follow up with future changes if I run into them.

Here's what the end result report looks like after some quick development work.

 

Screenshot 2024-09-09 at 8.19.57 AM.png

Like 3 people like this
0 votes
Sushil Bhattachan May 13, 2022

I am having the same challenge. Does any one know if there have been any update on API to give this data? 

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
SERVER
TAGS
AUG Leaders

Atlassian Community Events