Search code examples
githubsearchrepo

How to find all github repos that I starred / cloned


How to find all github repos that I starred / cloned, via API using curl?


Solution

  • If you're still looking, this is the endpoint:

    https://api.github.com/users/<your_username>/starred?per_page=<amount>&page=<num>
    

    The thing is though that it won't work like this by itself, you need to specify a special header:

    Accept: application/vnd.github.v3.star+json
    

    You'll probably also need to get a token for your account and use it in another header, otherwise you'll get rate limited pretty soon (you can only make 60 requests per minute without token).

    Authorization: token YOUR_TOKEN
    

    So everything combined in curl would look like this:

    curl \
    -H "Authorization: token $GITHUB_TOKEN" \
    -H "Accept: application/vnd.github.v3.star+json" \
    https://api.github.com/users/$USERNAME/starred\?per_page\=100\&page\=2
    

    Max per page amount is 100. You'll get huge chunks of json formatted text with a lot of unnecessary stuff that you'll have to parse through with some way, e.g. grep or you could try jq.

    There's some nice gists with complete scripts to fetch starred repos, both for Bash (curl) and Powershell, pretty sure you can find more by googling.