Created
April 17, 2016 14:34
-
-
Save zurfyx/8e22219811f15aab311409ae9162576b to your computer and use it in GitHub Desktop.
Github API - users who you are watching projects of
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
#!/usr/bin/env python | |
import requests | |
import json | |
import sys | |
def base_url(user): | |
return 'https://api.github.com/users/{0}/subscriptions'.format(user) | |
def retrieve(user): | |
url = base_url(user) | |
page = 0 | |
seen = set() | |
while True: | |
params = {'page': page} | |
page += 1 | |
data = json.loads(requests.get(url, params=params).text) | |
if not data: | |
break | |
for x in data: | |
name = x['full_name'].split('/')[0] | |
if name != user and name not in seen: | |
seen.add(name) | |
yield name | |
if __name__ == '__main__': | |
github_user = sys.argv[1] | |
for user in retrieve(github_user): | |
print user |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment