Skip to content

Instantly share code, notes, and snippets.

@MichaelCurrin
Last active August 27, 2020 11:21
Show Gist options
  • Save MichaelCurrin/0f4b1a7038d91e46fa4ade0038b754a1 to your computer and use it in GitHub Desktop.
Save MichaelCurrin/0f4b1a7038d91e46fa4ade0038b754a1 to your computer and use it in GitHub Desktop.
Get your recently starred repos from the GitHub GraphQL API

Get starred repos from GitHub

The GQL query in this gist will return details for repos which have been starred by the authenticating user.

Run

  1. Go to the GH GQL explorer and sign in.
  2. Copy the .gql query and paste it in.
  3. Press the run button.

If you want to get more than the last 100 repos, you'll need to use paging. I have a Python project MichaelCurrin/github-graphql-tool which handles that and generates a CSV of all the results. This query could be used there.

Extend

It doesn't seem possible to remove archived or private repos from the search like when getting repos owned by a user. However one can still filter the data using the fields in the results.

Or find starred repos of a given user. Replace viewer with user (login: "MichaelCurrin").

Learn more

Read more about GH GQL queries here, with steps and links to resources

https://gist.github.com/MichaelCurrin/6777b91e6374cdb5662b64b8249070ea

{
"data": {
"viewer": {
"starredRepositories": {
"nodes": [
{
"nameWithOwner": "phil-opp/talk-konstanz-may-2018",
"name": "talk-konstanz-may-2018",
"owner": {
"login": "phil-opp"
},
"description": null,
"updatedAt": "2020-08-25T13:42:35Z",
"createdAt": "2018-05-06T09:48:51Z",
"stargazers": {
"totalCount": 3
},
"forkCount": 0,
"primaryLanguage": {
"name": "HTML"
},
"languages": {
"nodes": [
{
"name": "HTML"
}
]
},
"isArchived": false,
"isPrivate": false
}
]
}
}
}
}
{
viewer {
starredRepositories (first: 100, orderBy: {field: STARRED_AT, direction: DESC}) {
nodes {
# Summary
nameWithOwner
name
owner {
login
}
description
#
# Dates
updatedAt
createdAt
#
# Counts
stargazers {
totalCount
}
forkCount
#
# Languages used
primaryLanguage {
name
}
languages (first: 100) {
nodes {
name
}
}
#
# State
isArchived
isPrivate
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment