-
-
Save sebble/e5af3d03700bfd31c62054488bfe8d4f to your computer and use it in GitHub Desktop.
#!/bin/bash | |
USER=${1:-sebble} | |
STARS=$(curl -sI https://api.github.com/users/$USER/starred?per_page=1|egrep '^Link'|egrep -o 'page=[0-9]+'|tail -1|cut -c6-) | |
PAGES=$((658/100+1)) | |
echo You have $STARS starred repositories. | |
echo | |
for PAGE in `seq $PAGES`; do | |
curl -sH "Accept: application/vnd.github.v3.star+json" "https://api.github.com/users/$USER/starred?per_page=100&page=$PAGE"|jq -r '.[]|[.starred_at,.repo.full_name]|@tsv' | |
done | |
echo | |
# curl -sI https://api.github.com/users/$USER/starred?per_page=100|egrep '^Link: '|tr , \\n|grep 'rel="next"'|egrep -o '<https[^>]+'|tr -d \< |
doesnt work
jq: error (at :4): Cannot index string with string "starred_at"
jq: error (at :4): Cannot index string with string "starred_at"
jq: error (at :4): Cannot index string with string "starred_at"
jq: error (at :4): Cannot index string with string "starred_at"
jq: error (at :4): Cannot index string with string "starred_at"
jq: error (at :4): Cannot index string with string "starred_at"
jq: error (at :4): Cannot index string with string "starred_at"
doesnt work jq: error (at :4): Cannot index string with string "starred_at" jq: error (at :4): Cannot index string with string "starred_at" jq: error (at :4): Cannot index string with string "starred_at" jq: error (at :4): Cannot index string with string "starred_at" jq: error (at :4): Cannot index string with string "starred_at" jq: error (at :4): Cannot index string with string "starred_at" jq: error (at :4): Cannot index string with string "starred_at"
You are running into non-authenticated api rate limiting. Generate a token:
https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token
The easiest way to use this token is to set it to the environment variable GITHUB_TOKEN.
doesnt work jq: error (at :4): Cannot index string with string "starred_at" jq: error (at :4): Cannot index string with string "starred_at" jq: error (at :4): Cannot index string with string "starred_at" jq: error (at :4): Cannot index string with string "starred_at" jq: error (at :4): Cannot index string with string "starred_at" jq: error (at :4): Cannot index string with string "starred_at" jq: error (at :4): Cannot index string with string "starred_at"
You need to do:
sudo apt-get install -y jq
and have a GITHUB_TOKEN
Powershell script using build-in JSON parsing:
https://gist.github.com/juergenhoetzel/1a0a73766a93942ed24722587f821edf