Home/Atlassian REST API reference
Jira and Confluence Cloud REST API
Count Jira work items matching a JQL query with the REST API
The enhanced JQL search no longer reports how many work items match. POST /rest/api/3/search/approximate-count takes the same jql and returns {"count": n}. The number is an estimate, and the query has to be bounded.
Endpoints
| Method | Path | What it does |
|---|---|---|
POST | /rest/api/3/search/approximate-count | Returns an estimated number of matching work items. |
POST | /rest/api/3/search/jql | Searches without returning a total. |
Examples
POST /rest/api/3/search/approximate-count
Counts the work items of one project.
curl
curl -X POST \
-u "you@example.com:$ATLASSIAN_API_TOKEN" \
-H 'Accept: application/json' \
-H 'Content-Type: application/json' \
--data '{
"jql": "project = WEB"
}' \
'https://your-domain.atlassian.net/rest/api/3/search/approximate-count'Python (requests)
import os
import requests
EMAIL = "you@example.com"
r = requests.post(
'https://your-domain.atlassian.net/rest/api/3/search/approximate-count',
auth=(EMAIL, os.environ["ATLASSIAN_API_TOKEN"]),
headers={'Accept': 'application/json'},
json={'jql': 'project = WEB'},
)
print(r.status_code, r.text)Response: HTTP 200
{
"count": 34
}Response headers
X-Ratelimit-Limit: 300Sent to Atlassian Cloud on .
POST /rest/api/3/search/jql
A normal search page for contrast. It holds no total, only a token and a flag.
curl
curl -X POST \
-u "you@example.com:$ATLASSIAN_API_TOKEN" \
-H 'Accept: application/json' \
-H 'Content-Type: application/json' \
--data '{
"jql": "project = WEB AND summary ~ \"REST API reference test\" ORDER BY created ASC",
"fields": [
"summary",
"status"
],
"maxResults": 1
}' \
'https://your-domain.atlassian.net/rest/api/3/search/jql'Python (requests)
import os
import requests
EMAIL = "you@example.com"
r = requests.post(
'https://your-domain.atlassian.net/rest/api/3/search/jql',
auth=(EMAIL, os.environ["ATLASSIAN_API_TOKEN"]),
headers={'Accept': 'application/json'},
json={'jql': 'project = WEB AND summary ~ "REST API reference test" ORDER BY created ASC',
'fields': ['summary', 'status'],
'maxResults': 1},
)
print(r.status_code, r.text)Response: HTTP 200
{
"issues": [
{
"key": "WEB-55"
}
],
"nextPageToken": "CkhjcmVhdGVkJmNyZWF0ZWQmT1JERVJfQVNDI0xvbmcmTVRjNU5UazNNek0xTlRZNU9BPT0lU3RyaW5nJlYwVkMlSW50Jk5UVT0QARiRle_CojQiSnByb2plY3QgPSBXRUIgQU5EIHN1bW1hcnkgfiAiUkVTVCBBUEkgcmVmZXJlbmNlIHRlc3QiIE9SREVSIEJZIGNyZWF0ZWQgQVNDKgJbXQ==",
"isLast": false
}Sent to Atlassian Cloud on .
POST /rest/api/3/search/jql
The bounded-query rule shown on the search endpoint. The spec states the count endpoint needs bounded JQL as well.
curl
curl -X POST \
-u "you@example.com:$ATLASSIAN_API_TOKEN" \
-H 'Accept: application/json' \
-H 'Content-Type: application/json' \
--data '{
"jql": "order by created DESC",
"maxResults": 1,
"fields": [
"summary"
]
}' \
'https://your-domain.atlassian.net/rest/api/3/search/jql'Python (requests)
import os
import requests
EMAIL = "you@example.com"
r = requests.post(
'https://your-domain.atlassian.net/rest/api/3/search/jql',
auth=(EMAIL, os.environ["ATLASSIAN_API_TOKEN"]),
headers={'Accept': 'application/json'},
json={'jql': 'order by created DESC', 'maxResults': 1, 'fields': ['summary']},
)
print(r.status_code, r.text)Response: HTTP 400
{
"errorMessages": [
"Unbounded JQL queries are not allowed here. Please add a search restriction to your query."
],
"errors": {}
}Sent to Atlassian Cloud on .
How it behaves
- A count request with jql set to project = WEB answered 200 with {"count": 34}.
- The search response from /search/jql has no total key, so a count means a separate call.
- The spec describes the result as an estimate and warns that recent updates might not be visible yet.
Pitfalls
- Do not use the count to size a loop or to stop paging. Page until isLast is true.
- An estimate right after creating or deleting work items can lag. Do not assert exact equality in tests.
- The count is the number of matching work items for the caller, limited to what the caller may browse.
Questions and answers
Is the count exact?
No. The spec calls it an estimate and says recent updates might not be visible.