Reputation: 7092
Is there a good way of getting the username and info for the ID in github?
Using ID I can currently get the avatar, but not any other user information.
eg: https://avatars.githubusercontent.com/u/2015
I have checked a similar question: Get github username by id
But the suggested answer does't seem to work any longer.
https://api.github.com/user/:2014 returns nothing.
Upvotes: 2
Views: 6081
Reputation: 5923
For anyone looking to do this using the GitHub v4 GraphQL API, here's how you do it:
{
node (id: "INSERT USERID") {
... on User {
id
login
}
}
}
The ... on User
lets you look up attributes specific to User
objects since a Node
could be any number of things (e.g. users, repos, commits). See an official answer by GitHub on their forum for more details.
Upvotes: 2
Reputation: 1085
your problem is quite a bit easy. You just missed few facts. I am clearing these for you ,
You have to check the GITHUB API V3 - for a grasp on how these api really works. which is helpful for future projects.
And please also the https://api.github.com/user/:2014
is used slightly wrong way. You see , you have to use it as https://api.github.com/user/2014
this way . In my case it is providing ,
{
"login": "lee",
"id": 2014,
"avatar_url": "https://avatars.githubusercontent.com/u/2014?v=3",
"gravatar_id": "",
"url": "https://api.github.com/users/lee",
"html_url": "https://github.com/lee",
"followers_url": "https://api.github.com/users/lee/followers",
"following_url": "https://api.github.com/users/lee/following{/other_user}",
"gists_url": "https://api.github.com/users/lee/gists{/gist_id}",
"starred_url": "https://api.github.com/users/lee/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/lee/subscriptions",
"organizations_url": "https://api.github.com/users/lee/orgs",
"repos_url": "https://api.github.com/users/lee/repos",
"events_url": "https://api.github.com/users/lee/events{/privacy}",
"received_events_url": "https://api.github.com/users/lee/received_events",
"type": "User",
"site_admin": false,
"name": null,
"company": null,
"blog": null,
"location": "New York, NY",
"email": null,
"hireable": null,
"bio": null,
"public_repos": 6,
"public_gists": 7,
"followers": 16,
"following": 7,
"created_at": "2008-03-03T14:23:14Z",
"updated_at": "2016-02-26T22:34:45Z"
}
so , I think this will solve the problem and wish you a great day . :)
Upvotes: 5