Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GitHub: How to avoid exceeding search limit while searching for account's details of users who contribute to some repository?

Let's say I need to list an amount of followers of each user who contribute to some repository (using JavaScript).

First, I use this:

    $.ajax({ 
        headers: { Authorization: "Basic " + auth },
        type: 'GET', 
        url: 'https://api.github.com/repos/[reponame]/angular/contributors', 
        dataType: 'json',
        success: function (data) { 
            repositories = data;
            outputPageContent();
        }
    });

I get the JSON list of users, but there's no information about an amount of followers of each of them. I thought I'd ask for it separately (in a loop), using "url" like:

https://api.github.com/users/repositories[i].login

But in this way I'm exceeding the search limit at once (up to 30 per minute for registered users).

Have you any idea how to solve this problem? Maybe some nested request?

I also have some additional questions:

  1. At first I thought it'd be a good move to use "OR" logical operator and request something like "give me all users who login = loginA OR login login = loginB OR login = loginC" etc. But I failed to find how to use "or" logical operator in github api.

  2. How is it possible you can:

"For requests using Basic Authentication or OAuth, you can make up to 5,000 requests per hour. "

But you can make only 30 request per minute? Wouldn't it be 30*60 = 1800 requests per hour then?

like image 524
user3581955 Avatar asked Nov 10 '22 01:11

user3581955


1 Answers

A query like this is possible using Github v4 API. Try this out in the API Explorer

query { 
  repository (name: "angular", owner: "angular") {
    assignableUsers (first: 100) {
      edges {
        node {
          id
          login
          followers {
            totalCount
          }
        }
      }
    }
  }
}
like image 53
Oluwafemi Sule Avatar answered Nov 14 '22 21:11

Oluwafemi Sule