Skip to content

Instantly share code, notes, and snippets.

@acanimal
Created December 24, 2020 17:21
Show Gist options
  • Save acanimal/4dfdf7b6f238ec1e089bb3a90430b0a5 to your computer and use it in GitHub Desktop.
Save acanimal/4dfdf7b6f238ec1e089bb3a90430b0a5 to your computer and use it in GitHub Desktop.
GraphQL query to get github user stats
import { Octokit } from "@octokit/rest";
// Go to github settings and create a token. Add permissions for user/email
const auth_token = 'YOUR TOKEN';
const octokit = new Octokit({
auth: auth_token,
});
const response = await octokit.graphql(`
query {
user(login:"${user}") {
createdAt
email
followers {
totalCount
}
following {
totalCount
}
gists {
totalCount
}
location
login
name
organizations {
totalCount
}
pullRequests {
totalCount
}
twitterUsername
websiteUrl
repositories(first: 100, privacy: PUBLIC) {
totalCount
edges {
node {
forkCount
stargazerCount
languages(first: 10) {
edges {
size
node {
name
}
}
}
}
}
}
}
rateLimit {
limit
cost
remaining
resetAt
}
}
`);
console.log(JSON.stringify(response, null, 2));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment