Search code examples
githubgithub-api

How many user limit searches will github have?


I'm trying to search the repository using github api, and I wonder how many people limit the number of people I can search.

For example, I'm trying to write an api as below, and I'm wondering how many people "user:XXX" is here.

https://api.github.com/search/repositories?q=user:taetaetae+user:black9p+user:asuraiv

I want you to help me with how many people are supported and if there are related documents.

Thank you.


Solution

  • For the search api, you are limited by the maximum size of the search query which is 256 characters :

    The Search API does not support queries that:

    • are longer than 256 characters (not including operators or qualifiers).
    • have more than five AND, OR, or NOT operators. These search queries will return a "Validation failed" error message.

    But if you want to reduce the number of request, you can use GraphQL api and the following request using aliases:

    query { 
      user0: user(login: "taetaetae") {
        name
        login
        createdAt
      }
      user1: user(login:"black9p"){
        name
        login
        createdAt
      }
      user2: user(login:"asuraiv"){
        name
        login
        createdAt
      }
    }
    

    You could also use fragments :

    query { 
      user0: user(login: "taetaetae") {
        ...UserFragment
      }
      user1: user(login:"black9p"){
        ...UserFragment
      }
      user2: user(login:"asuraiv"){
        ...UserFragment
      }
    }
    fragment UserFragment on User {
      name
      login
      createdAt
    }
    

    Output :

    {
      "data": {
        "user0": {
          "name": "taetaetae",
          "login": "taetaetae",
          "createdAt": "2015-02-12T02:27:40Z"
        },
        "user1": {
          "name": "Seongduck Paek",
          "login": "black9p",
          "createdAt": "2018-01-07T11:53:13Z"
        },
        "user2": {
          "name": "Ju Pyo Hong",
          "login": "asuraiv",
          "createdAt": "2017-08-04T16:23:09Z"
        }
      }
    }
    

    Try this in the explorer