Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pagination in Gitlab API only returns 100 per_page max

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.

like image 916
Dante Avatar asked Nov 21 '17 13:11

Dante


1 Answers

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. See https://docs.gitlab.com/ee/api/README.html#pagination-link-header

like image 134
Sascha Frinken Avatar answered Sep 24 '22 16:09

Sascha Frinken