How to get issue count using JQL in jira?

Nagaveer June 11, 2014

I need to get issue count based on filter using JQL.

for ex.

filter-> project in(ADMIN,MANGMNT) AND "Name" ~ "admin"

JQL needs to be used through REST API.

please help

7 answers

1 accepted

10 votes
Answer accepted
Andreas Ebert
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.
June 11, 2014

There is no REST resource that returns ONLY the count, but you can use /rest/api/2/search?jql=YOUR_JQL_QUERY and then look at the result object. It will contain an attribute "total" which is the count you want.

Straight from the api doc:

{
    "expand": "names,schema",
    "startAt": 0,
    "maxResults": 50,
    "total": 1, // <- you want this value
    "issues": [
        {
            "expand": "",
            "id": "10001",
            "self": "http://www.example.com/jira/rest/api/2/issue/10001",
            "key": "HSP-1"
        }
    ]
}

 
Ofer Prat October 25, 2017

Thanks!

Bill Cowden July 19, 2018

Setting "maxResults=0" only returns the metadata without the rows if you're only interested in the total:

rest/api/2/search?jql=project=YOUR_PROJECT&maxResults=0
Like # people like this
Matt December 19, 2018

Nice, thanks Bill

Hugo December 22, 2020

Thanks a lot Bill!!!

Bilal Khan November 13, 2023

Nice, thanks Bill (3)

13 votes
Jose Ramirez October 31, 2018

Is there an straight JQL equivalent for this ?

2 votes
Robert_Hall April 16, 2020

Well you can could just do a normal JQL  query

issuetype = 'Test' and TestRunStatus = "pass" and assignee = <UserName>

Then tools will give a count for the query

A bit of a bodge but does tell you what you need to know

image.png

Nethra March 16, 2021

This has a limitation, it will not show the actual count for entries more than 1000.

Like bennoll likes this
2 votes
Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
June 11, 2014

Save the filter and look at it - most of the ways of viewing a filter will give you totals.

Note that JQL is NOT SQL, and it doesn't have anything to say about the results it pulls back. All it does is give other parts ofthe system list of issues to work with.

Nagaveer June 11, 2014

Thanks Nic.

Would you suggest an alternate way to get only count via any REST API method?

Like Sakthivel likes this
Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
June 11, 2014

Run the filter and then write some code that adds up the totals in whatever application is you've written the REST code into

1 vote
Jesse Rivera May 20, 2021

The best way I have found, using Zephyr Jira is to use the options under Export, inside the Filters page. 

Once you have created your jql query, Click on Export, you will see the Print list option.

Clicking on Print List will open a new tab with the same list from the last page. 

It will also give you this line:  – ### of ### as at: Day/Month/Year Time.

That ### is the number you are looking for. 

 

Print List Option: 

Print List JQL Query.png

 

Printed List: 

Printed List Query.png

0 votes
Smita May 3, 2020

Execute a CURL command for your project specifically like this on command line and pipe more. The first line shows "total" issues in your project

e.g

COMMAND

D:\curl -D- -u username:password -X GET -H "Content-Type: application/json" http://localhost:8081/rest/api/2/search?jql=project='ABC' | more

OUTPUT

...

...

100 501k 0 501k 0 0 501k 0 --:--:-- --:--:-- --:--:-- 892k
{"expand":"schema,names","startAt":0,"maxResults":50,"total":219,"issues":[{"expand":"operations,versionedRepresentations,editmeta,changelog,renderedFields"

....

....

namrata singhal July 17, 2020

I need to get the record count and then show it on confluence - is this possible?

Anders Dyhrberg July 28, 2020

You are in luck @namrata singhal for confluence this is built in.

1: When editing add "Jira Issue/Filter"
2: After you have made your filter. Select "Display Options" and the "Total Issue Count"

totalcount.png

Like # people like this
Lawrence July 29, 2020

Is there a way to change the font type/size of the displayed count in confluence?

Marc Isikoff February 22, 2023

This is the issue we are having: We want to find possible duplicates based on a custom field.

We can implement the above in Confluence, but we cannot give it a form response for the custom field; Jira has no JQL scope for outside of a single issue.

And we cannot use the Marketplace so we are looking everywhere for JQL or Confluence solution for entering a value and getting a count back when basing the custom field value against "the field".

0 votes
swati_dave February 18, 2020

If you want to get issue count output you can setup query using generate api

for example if you want project base issue count then you can apply this rest api for that

URL :- "/rest/gadget/1.0/stats/generate.json?projectOrFilterId=jql-ORDER+BY+created+DESC&statType=project&includeResolvedIssues=true&sortDirection=desc&sortBy=total"

Hear in "projectOrFilterId" you can set your jql query and "statType" as like a groupBy.

Srot Sinha October 3, 2020

I need to count of tickets for each project. I tried above mentioned API but it's returning me error

Invalid JQL query specified for chart \'ORDER+BY+created+DESC\'

I tried with another API  wherein projectOrFilterId=jsql-create+&gt+created and I got same issue again.

API works if I give a hardcoded project id though.

Thanks

Suggest an answer

Log in or Sign up to answer