Skip to content

Instantly share code, notes, and snippets.

@jmpinit
Created August 23, 2020 15:57
Show Gist options
  • Select an option

  • Save jmpinit/d18cda261bc1b6cd2237a0200a5c04bf to your computer and use it in GitHub Desktop.

Select an option

Save jmpinit/d18cda261bc1b6cd2237a0200a5c04bf to your computer and use it in GitHub Desktop.
Use the GitHub API to retrieve all of a user's stars.
# Combine with https://gist.github.com/jmptable/d961e792902b87f6ffccf0d69d900413
import json
import time
import requests
def get_stars(user):
page = 0
stars = []
while True:
req = requests.get('https://api.github.com/users/{}/starred'.format(user), params={'page': page})
res = req.json()
if len(res) > 0:
stars += res
else:
break
print('Got page #{}'.format(page))
page += 1
time.sleep(1)
return stars
stars = get_stars('jmptable')
with open('stars.json', 'w') as stars_file:
stars_file.write(json.dumps(stars))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment