Skip to content

Instantly share code, notes, and snippets.

@justlaputa
Last active September 29, 2024 10:33
Show Gist options
  • Save justlaputa/a6da84981eca963817e652b5f2452cfc to your computer and use it in GitHub Desktop.
Save justlaputa/a6da84981eca963817e652b5f2452cfc to your computer and use it in GitHub Desktop.
How to unstar all your github starred repos

About

How to unstar all your github stars with API

Generate a github personal token

visit here: https://github.com/settings/tokens make sure to check repo scope, it is needed to unstar

Get all starred repos

set apikey as env variable

export APIKEY=xxxxxxxxx

first get total number of pages of your star

curl -I -H "Authorization: token $APIKEY" https://api.github.com/user/starred
HTTP/1.1 200 OK
...
Link: <https://api.github.com/user/starred?page=2>; rel="next", <https://api.github.com/user/starred?page=4>; rel="last"
...

then iterate on all pages (1 to 4)

for p in `seq 1 4`;do
echo page 
curl -s -H "Authorization: token $APIKEY" https://api.github.com/user/starred\?page\=$p | jq -r '.[] |.full_name' >>stars.txt
done

finally delete all repos in the stars.txt file

while read REPO;do
echo ${REPO}
curl -X DELETE -s -H "Authorization: token $APIKEY" "https://api.github.com/user/starred/$REPO"
sleep 0.5
done<stars.txt
@justlaputa
Copy link
Author

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment