Sergei Patiakin
Sergei Patiakin

Reputation: 276

GitHub API - latest public repositories

I would like to list public GitHub repositories with the latest create/update/push timestamps (for me any of these is acceptable). Can I achieve this with the GitHub API?

I have tried the following:

  1. Tried using /repositories endpoint, and use the link header to navigate to the last page. However, the link header I receive only has first and next links, whereas I need a last link.

  2. Tried using /search/repositories endpoint. This will work as long as I have a keyword or filter in the q parameter, but it will not accept an empty q parameter.

Upvotes: 2

Views: 75

Answers (1)

Sergei Patiakin
Sergei Patiakin

Reputation: 276

I got in touch with GitHub support, and there are two solutions to this:

  1. Use binary search on the since parameter of the /repositories endpoint to find the last page. Cons: may quickly exhaust the API rate limit.

  2. Use the /search/repositories endpoint with an always-true predicate such as stars>=0. Cons: likely to cause a query timeout/ incomplete results.

Upvotes: 1

Related Questions