Created
November 22, 2019 20:38
-
-
Save spg/1e6e3dfa711cd3dc427532480e9f986b to your computer and use it in GitHub Desktop.
Get views
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
#!/bin/sh | |
GH_TOKEN=$1 | |
curl -s -H "Authorization: token $GH_TOKEN" https://api.github.com/users/sindresorhus/repos\?page\=1\&per_page\=100 | jq -r '.[] | .name' >> repos.txt | |
curl -s -H "Authorization: token $GH_TOKEN" https://api.github.com/users/sindresorhus/repos\?page\=2\&per_page\=100 | jq -r '.[] | .name' >> repos.txt | |
curl -s -H "Authorization: token $GH_TOKEN" https://api.github.com/users/sindresorhus/repos\?page\=3\&per_page\=100 | jq -r '.[] | .name' >> repos.txt | |
curl -s -H "Authorization: token $GH_TOKEN" https://api.github.com/users/sindresorhus/repos\?page\=4\&per_page\=100 | jq -r '.[] | .name' >> repos.txt | |
curl -s -H "Authorization: token $GH_TOKEN" https://api.github.com/users/sindresorhus/repos\?page\=5\&per_page\=100 | jq -r '.[] | .name' >> repos.txt | |
curl -s -H "Authorization: token $GH_TOKEN" https://api.github.com/users/sindresorhus/repos\?page\=6\&per_page\=100 | jq -r '.[] | .name' >> repos.txt | |
curl -s -H "Authorization: token $GH_TOKEN" https://api.github.com/users/sindresorhus/repos\?page\=7\&per_page\=100 | jq -r '.[] | .name' >> repos.txt | |
curl -s -H "Authorization: token $GH_TOKEN" https://api.github.com/users/sindresorhus/repos\?page\=8\&per_page\=100 | jq -r '.[] | .name' >> repos.txt | |
curl -s -H "Authorization: token $GH_TOKEN" https://api.github.com/users/sindresorhus/repos\?page\=9\&per_page\=100 | jq -r '.[] | .name' >> repos.txt | |
curl -s -H "Authorization: token $GH_TOKEN" https://api.github.com/users/sindresorhus/repos\?page\=10\&per_page\=100 | jq -r '.[] | .name' >> repos.txt | |
curl -s -H "Authorization: token $GH_TOKEN" https://api.github.com/users/sindresorhus/repos\?page\=11\&per_page\=100 | jq -r '.[] | .name' >> repos.txt | |
curl -s -H "Authorization: token $GH_TOKEN" https://api.github.com/users/sindresorhus/repos\?page\=12\&per_page\=100 | jq -r '.[] | .name' >> repos.txt | |
curl -s -H "Authorization: token $GH_TOKEN" https://api.github.com/users/sindresorhus/repos\?page\=13\&per_page\=100 | jq -r '.[] | .name' >> repos.txt | |
curl -s -H "Authorization: token $GH_TOKEN" https://api.github.com/users/sindresorhus/repos\?page\=14\&per_page\=100 | jq -r '.[] | .name' >> repos.txt | |
curl -s -H "Authorization: token $GH_TOKEN" https://api.github.com/users/sindresorhus/repos\?page\=15\&per_page\=100 | jq -r '.[] | .name' >> repos.txt | |
curl -s -H "Authorization: token $GH_TOKEN" https://api.github.com/users/sindresorhus/repos\?page\=16\&per_page\=100 | jq -r '.[] | .name' >> repos.txt | |
echo "repo,count,uniques" >> views.csv | |
cat $repos.txt | while read reponame | |
do | |
DATA=`curl -s -H "Authorization: token $GH_TOKEN" https://api.github.com/repos/sindresorhus/$reponame/traffic/views?per=week | jq -r '"\(.count),\(.uniques)"'` | |
echo "$reponame,$DATA" >> views.csv | |
done |
There's a tiny bug in a script: $repos.txt
=> repos.txt
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Prerequisites:
To run this script:
e.g.: