How do I get multiple users at once using the GitHub API?

I can get one user or all users created from a timestamp or where there is a search mapping to the GitHub API.

https://developer.github.com/v3/users/#get-a-single-user https://developer.github.com/v3/users/#get-all-users https: //developer.github. com / v3 / search / # search-users

What I haven't been able to figure out is a way to send something like a list of logins and return all those users at once.

My use is that I select a list of organization members. This gives me a fair amount of data that I could loop through each individual user and get the detailed user data I need so badly, but I'd rather not cram the GitHub API with a bunch of extra requests if that's not necessary.

+3


source to share


1 answer


Using GraphQL API v4 , you can create a dynamic query with as many users as you have in your array and use aliases for each one:

query {
  user1: user(login: "aisalmi") {
    ...UserFragment
  }
  user2: user(login: "bertrandmartel") {
    ...UserFragment
  }
  user3: user(login: "molokoloco") {
    ...UserFragment
  }
}

fragment UserFragment on User {
  login
  name
}

      



I also use fragment to avoid duplicate field

Test it in File Explorer

+1


source







All Articles