I'm trying to create a page that will show me how many incidents have happened within a month via the Jira api, I'm not sure the best way to fo this as I have looked through the jira api docs but that is not described within.
-
I have an array being returned but I'm not sure how to only get this information ' `Array ( [expand] => schema,names [startAt] => 0 [maxResults] => 5 [total] => 840 [issues] => Array (` I want to pull back the total amount of incidents. – Zextia Feb 29 '16 at 12:30
-
The `total` (numeric) is how many "incidents" were found. The `startAt` and `maxResults` are for the paging. In your example, the answer is: 840. – Koshinae Feb 29 '16 at 15:24
1 Answers
If by "how many incidents happened" you mean "how many issues were created" you can do a JQL search, which gives you a total count of issues within specified JQL query.
So to find issues created in February 2016 you should use the following JQL: created >= 2016-02-01 AND created <= 2016-02-29
. The REST API endpoint that lets you perform a JQL search is /api/2/search.
In our example (issues created in February) you need to send a GET request to:
{YOUR_JIRA_BASE_URL}/rest/api/2/search?jql=created%20>=%202016-02-01%20AND%20created%20<=%202016-02-29
(don't forget to properly encode the query string)
To save bandwidth you can discard issues data and retrieve only the count by adding a maxResults
parameter set to 0:
{YOUR_JIRA_BASE_URL}/rest/api/2/search?maxResults=0&jql=created%20>=%202016-02-01%20AND%20created%20<=%202016-02-29
Here's a concrete example using the Apache's JIRA: Issues created in February
REFERENCE
JQL is quite powerful so you can narrow down your search even further (e.g. specify project to count the issues for). Read more about it here and here

- 4,843
- 1
- 23
- 53