23

I am currently using GitLab API to return all projects within a group. The question I have is, how do I return all projects if there are over 100 projects in the group?

The curl command I'm using is curl --header "PRIVATE-TOKEN: **********" http://gitlab.example.com/api/v4/groups/myGroup/projects?per_page=100&page=1

I understand that the default page=1 and the max per_page=100 so what do I do if there are over 100 projects? If I set page=2, it just returns all the projects after the first 100.

Dante
  • 548
  • 1
  • 7
  • 19
  • 4
    You have to iterate until the max count is reached or nothing is returned and then concat the results – cfrick Nov 21 '17 at 15:51

1 Answers1

38

Check the response for the X-Total-Pages header. As long as page is smaller than total pages, you have to call the api again and increment the page variable. https://docs.gitlab.com/ee/api/rest/index.html#pagination-link-header

hatirlatici
  • 1,598
  • 2
  • 13
  • 24
Sascha Frinken
  • 3,134
  • 1
  • 24
  • 27