Home > OS >  GitHub API: How to list in single call both protected and non-protected branches (`/repos/OWNER/REPO
GitHub API: How to list in single call both protected and non-protected branches (`/repos/OWNER/REPO

Time:11-25

According to the documentation omitting protected parameter should list all the branches from the repository.

protected

Setting to true returns only protected branches. When set to false, only unprotected branches are returned. Omitting this parameter returns all branches.

But with angular repository, it's listing only protected branches (even not sure that all of them) https://api.github.com/repos/angular/angular/branches One nothing is that the default main branch is not listed even under the protected flag. The tags endpoint is not listed on API documentation but seems like it returns truncated data as well.

CodePudding user response:

The branches are paged, by default the API returns only the first 30:

per_page integer

The number of results per page (max 100).

Default: 30

page integer

Page number of the results to fetch.

Default: 1

More details in how GitHub implements pagination can be found in the docs.

  • Related