Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

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

7 answers

1 accepted

10 votes
Answer accepted

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 # people like this

Nice, thanks Bill

Thanks a lot Bill!!!

Is there an straight JQL equivalent for this ?

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

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

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?

Like Sakthivel likes this

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

0 votes

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

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"

....

....

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

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

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

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.

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
TAGS

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you