Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How to fetch List of Existing Labels from Jira Software (DC) via API Call?

Digvijay Singh Gehlot
Contributor
February 5, 2025

Hi Community,

Please guide on how generate a list of existing labels present in Jira Software (Data Center) via API call.

It will be a great help you could share necessary help document and syntax code to generate the same via API call.

Thanks

2 answers

1 accepted

2 votes
Answer accepted
Layssa Souza
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.
February 5, 2025

Hi @Digvijay Singh Gehlot 

In Jira Data Center, there is no native REST API endpoint that directly provides a list of all existing labels. However, there are some alternatives to obtain this information.

 

You can use the issue search REST API (/rest/api/2/search) and extract the labels from the results.

Endpoint

/rest/api/2/search?jql=labels IS NOT EMPTY&fields=labels&maxResults=1000

Example of Usage with cURL 

curl -u "seu_usuario:seu_token" -X GET \
"https://SEU_JIRA_URL/rest/api/2/search?jql=labels IS NOT EMPTY&fields=labels&maxResults=1000" \
-H "Content-Type: application/json"

Retorno.png 

I hope this helps you.

Best Regards.

 

0 votes
Vishal Biyani
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.
February 5, 2025

@Digvijay Singh Gehlot 

Below is a pseudo code that you could use

Use below jql and narrow it down as much possible say by adding condition like statusCategory != Done

 

then use below rest end point 

url = "https://your-domain.atlassian.net/rest/api/3/search/jql"

headers = { "Accept": "application/json" }

auth = HTTPBasicAuth("email@example.com", "<api_token>")

query = {

'jql': 'labels is not EMPTY',

'maxResults': 100, 'fields': '[key, labels]'

}

response = requests.request( "GET", url, headers=headers, params=query, auth=auth )

and then loop based on nextPageToken

 

 

Suggest an answer

Log in or Sign up to answer