How to retrieve multiple users at once with the GitHub API?
github, github-api
Solution
Using GraphQL API v4, you could build a dynamic query with as many user you have in your array & 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 a fragment to avoid field duplication
Test it in the explorer
Problem
I'm able to get a single user, or all users created since a timestamp, or where there is some search match with 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 if there is a way to send something like a list of logins and get back all of those users at once. My use case is that I'm pulling back a list of members off of an org. This provides me with enough data that I could loop through each individual user and get the detailed user data that I need this way, but I would rather not be hammering GitHub's API with a bunch of extra requests if it is not necessary.