Search code examples
gitlabgitlab-api

how to retrive all commits of a special branch with gitlab api v4?


For example, my project id is 385, and I want to retrive all commits of branch 'V3.53.5' with gitlab api v4, the url is http://{ip}/api/v4/projects/385/repository/commits/?ref_name=V3.53.5&per_page=9999, the problem is that it only return some commits even with the parameter per_page=9999.

While gitlab api v3 doesn't have this problem. I cant get all commits with http://{ip}/api/v3/projects/385/repository/commits/?ref_name=V3.53.5&per_page=9999

But I just want to use api v4, what should I do? I don't find an answer to my question in Gitlab API docs


Solution

  • GitLab API has a max 100 per page: https://docs.gitlab.com/ee/api/#pagination

    What you should do is retrieve X-Total-Pages: <total_pages> and iterate over each page adding the URL parameter &page=<page>