How to get issue count using JQL in jira?

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

3 answers

1 accepted

7 votes
Accepted answer

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"
        }
    ]
}

 

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 1 person likes this

Nice, thanks Bill

2 votes

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.

Thanks Nic.

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

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

Is there an straight JQL equivalent for this ?

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Wednesday in Jira

Make your Atlassian Cloud products more secure: our NEW admin security guide

Hey admins! I’m Dave, Principal Product Manager here at Atlassian working on our cloud platform and security products. Cloud security is a moving target. As you adopt more products, employees consta...

155 views 0 6
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you