How to get JIRA projects with pagination through rest api?

Ashish Bijlwan May 16, 2018

Hi,

We have more than 50 projects in jira and we want only first 10 projects in our app and later 10 more.how can we achieve this through jira rest api?

Regards

Ashish

5 answers

1 accepted

0 votes
Answer accepted
Kirubel Tesfaye
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.
May 17, 2018

Hi @Ashish Bijlwan,

If you refer to documentation for the Jira rest api you used, you will see that it return list of all of project visible for the currently logged in user, i.e. all the projects the user has either ‘Browse projects’ or ‘Administer projects’ permission.

So the solution I have found is that either to use a user that has access to only the 10 project or use the recent property.

Ashish Bijlwan May 17, 2018

Hi @Kirubel Tesfaye,

So there is  no way of pagination while getting project list?

Kirubel Tesfaye
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.
May 17, 2018

hello again @Ashish Bijlwan,

The documentation vaguely state that pagination is enforced for methods that could return a large collection of items without clearly defining how much large is.  I think they assumed that list of projects couldn't be large and didn't enforce pagination on this api.

So instead use the recent query parameter, which if set returns Only projects recently accessed by the current user. If no user is logged in, recently accessed projects will be returned based on current HTTP session. Maximum count is limited to the specified number, but no more than 20.

Hope this Helps!

Ashish Bijlwan May 17, 2018

Screen Shot 2018-05-17 at 4.03.59 PM.pngIf that is the case then how they are achieving pagination in  their JIRA website?

Kirubel Tesfaye
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.
May 17, 2018

Hello again @Ashish Bijlwan,

This is different kind of pagination. This kind of pagination is created using HTML & CSS

The pagination we are talking about is different.

Ashish Bijlwan May 17, 2018

Ok..means you want to say that their also they are getting all project at a time but by using html/css/javascript ,they are showing in form of pagination

Kirubel Tesfaye
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.
May 17, 2018

Yes

Ashish Bijlwan May 17, 2018

OK..Thanks @Kirubel Tesfaye 

2 votes
Guntur Nitin Shashank July 15, 2021

Try this,

<org_url>/rest/api/latest/search?project=<project_key>&startAt=0&maxResults=50

1 vote
Dhruv Dixit February 25, 2019

For the recently accessed 10 projects use:

<org URL>/rest/api/2/project?recent=10&maxResults=10

0 votes
Aniruddha Gayake October 21, 2021
0 votes
Rambabu Patina _Appfire_
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.
May 16, 2018

You may have a look at pagination section in https://developer.atlassian.com/server/jira/platform/rest-apis/

Clients can use the startAt, maxResults,andtotal parameters to retrieve the desired number of results.

Ashish Bijlwan May 16, 2018

Hi,

this is the  rest api for getting the project list :-<org URL>/rest/api/2/project

i am also passing startAt and maxResults parms but not getting limited data.

<org URL>/rest/api/2/project?startAt=0&maxResults=10

Rambabu Patina _Appfire_
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.
May 17, 2018

Try add the 'total' parameter something like <org URL>/rest/api/2/project?startAt=0&maxResults=10&total=100

Ashish Bijlwan May 17, 2018

ok..let me check

Ashish Bijlwan May 17, 2018

not working...still getting all projects list

Like Esther de Mattos Silva likes this
于志鹏 December 5, 2018

yes I have try this  and get all projects list I think I need to use recent instead startAt

Like zqh likes this

Suggest an answer

Log in or Sign up to answer