Skip to content

Instantly share code, notes, and snippets.

@mekarpeles
Created November 2, 2012 00:02
Show Gist options
  • Save mekarpeles/3997726 to your computer and use it in GitHub Desktop.
Save mekarpeles/3997726 to your computer and use it in GitHub Desktop.
A demonstration of using the Github API to access public user data
#-*- coding: utf-8 -*-
import requests
def user(username):
"""
>>> print(user('mekarpeles'))
{u'public_repos': 23, u'public_gists': 2, u'name': u'Michael E. Karpeles', u'created_at': u'2011-08-13T20:01:14Z', u'url': u'https://api.github.com/users/mekarpeles'\
, u'company': u'Hyperink', u'html_url': u'https://github.com/mekarpeles', u'id': 978325, u'blog': None, u'hireable': True, u'avatar_url': u'https://secure.gravatar.com/a\
vatar/7ca82283af0b65b163dde4f5f5e3fb41?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-user-420.png', u'followers': 22, u'location': u'San \
Francisco', u'bio': None, u'gravatar_id': u'7ca82283af0b65b163dde4f5f5e3fb41', u'following': 19, u'login': u'mekarpeles', u'type': u'User', u'email': u'michael.karpeles@\
gmail.com'}
"""
x = requests.get('https://api.github.com/users/{}'.format(username))
return x.json
if __name__ == "__main__":
print(user('mekarpeles'))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment