Skip to content

Instantly share code, notes, and snippets.

@ratulotron
Last active August 27, 2016 23:51
Show Gist options
  • Save ratulotron/30fbd4e6fd3177a53f83 to your computer and use it in GitHub Desktop.
Save ratulotron/30fbd4e6fd3177a53f83 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
"""Script to get Github info using API"""
import requests
# main URL that doesn't get changed
baseurl = "https://api.github.com/users/"
# add any number of usernames here
users = ['kennethreitz', 'mitsuhiko', 'jkbrzt', 'nvbn', 'donnemartin']
# Which JSON properties we want to catch
properties = ['name', 'id', 'html_url', 'public_repos', 'created_at']
# run loop through all the users
for username in users:
# make API url with Github username
current_user = baseurl + username
# take response from the url
response = requests.get(current_user)
# conversion to human readable format
user_info = response.json()
# print all the properties
for property in properties:
print("{}: {}".format(property, user_info[property]))
print('')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment