Is it possible to make batch requests on the github api?
Asked Answered
R

2

5

I want to be able to get an array of users for a series of repositories. As far as I know, the only way to achieve that is to loop through the repositories and make a request for each. Unfortunately, this eats up my api-hit-count, which is limited to 5000/hour. Is there a way that I can pass up an array of repositories, and get an 2d array of JSON?

Note: I'm writing this using node.js

Current situation

for( var iRepo=0; iRepo<repos.length; ++iRepo )
    request(repo.stargazers_url, parseUserCallback )

I want to do

request( batchEndpoint, {repos:repos}, parseRepoUserMapCallback )

This seems like something that could be solved with a simple google search, but searching for anything with "GitHub" in it just brings up various repositories.

Renascent answered 22/7, 2014 at 4:40 Comment(0)
A
5

Sadly, GitHub's API documentation has no signs of any form of batch operations for this endpoint.

So you might want to do caching or figure out something else.

Almeta answered 22/7, 2014 at 5:29 Comment(1)
That's correct -- the GitHub API doesn't support batch operations currently.Loos
A
2

The better way to perform such an operation would be to use the GitHub GraphQL API. GraphQL allows you to get exactly and only what you need from the API.

I suggest you consider abandoning the REST api and switching to the GraphQL one.

Acquah answered 5/6, 2021 at 16:28 Comment(1)
Good idea but it's worth noting the GraphQL API and REST API support different features. E.g. there doesn't appear to be a GraphQL connection between repos and GH Actions workflows so I couldn't batch requests for repo workflows. Had to stick with the REST API instead.Thermochemistry

© 2022 - 2024 — McMap. All rights reserved.