18

I use the GitLab API to fetch a list of the projects I have access to (URL /api/v3/projects/all?private_token=xxx), but there are 6-7 projects that are not included in the list for some reason.

EDIT: My user is an administrator, and I want to list all projects like the /projects/all URL indicates.

I have access to the projects just fine using git itself and the GitLab web interface. Any suggestions why the projects wouldn't be shown in the list from the API?

All the projects missing are newer than the others. I have tried refreshing my API token; no change.

Versions:

GitLab        6.4.3
GitLab Shell  1.8.0
GitLab API    v3
Ruby          2.0.0p353
Rails         4.0.2
27
+50

I just tested this and it looks like the GitLab API response is using pagination. According to the documentation (http://api.gitlab.org), the default number of results per page is set to 20 and the starting page is 1.

To adjust the maximum results per page, you need to use the per_page variable in the HTTP request line. You can change the page number by using page as well, if you have more repositories than the maximum value of per_page. You can specify a maximum per_page value of 100.

For example, you request may look like:

https://git.example.com/api/v3/projects/all?page=1&per_page=100&private_token=abc123

The page and per_page variables are not required as they have default values, so you do not need to include either if you don't want to.

Hopefully this solves your problem.

  • It does indeed! I feel lazy and stupid now ;) Thanks a lot! – Nils Feb 6 '14 at 13:35
  • No problems, a lesson learned for myself too :) – jaseeey Feb 6 '14 at 23:04
  • 1
    Is there any way to return more than 100? My result of user activity is far more than 100 but the api only returns the max of 100. – emmdee Feb 5 '18 at 20:55
  • From looking at the API documentation, it looks like the maximum per_page value allowed is 100. Refer: docs.gitlab.com/ce/api/README.html#pagination – jaseeey Feb 7 '18 at 4:50
0

yes, it works with pagination you need to change the "page" parameter value and call multiple times as follows.

https://gitlab.example.com/api/v3/projects/all?page=1&per_page=100&private_token=some_token

https://gitlab.example.com/api/v3/projects/all?page=2&per_page=100&private_token=some_token

-1

If you aren't sure about number of pages use it as below: https://git.example.com/api/v3/projects/all?per_page=-1&private_token=some_token_key

  • does not list all the projects... only give default 20 records – Saurabh May 24 '16 at 12:27
  • Same to me. Only shows default 20 items in the first page – Marslo Jan 20 '17 at 9:54
  • doesn't do anything, only returns default 20 – Ivan Oct 26 '17 at 12:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.