Created
December 24, 2020 17:21
-
-
Save acanimal/4dfdf7b6f238ec1e089bb3a90430b0a5 to your computer and use it in GitHub Desktop.
GraphQL query to get github user stats
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
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