We are working on a project where we need to display all the projects of a person in his repository on GitHub account.
Can anyone suggest, how can I display the na
Use the Github API:
/users/:user/repos
This will give you all the user's public repositories. If you need to find out private repositories you will need to authenticate as the particular user. You can then use the REST call:
/user/repos
to find all the user's repos.
To do this in Python do something like:
USER='AUSER'
API_TOKEN='ATOKEN'
GIT_API_URL='https://api.github.com'
def get_api(url):
try:
request = urllib2.Request(GIT_API_URL + url)
base64string = base64.encodestring('%s/token:%s' % (USER, API_TOKEN)).replace('\n', '')
request.add_header("Authorization", "Basic %s" % base64string)
result = urllib2.urlopen(request)
result.close()
except:
print 'Failed to get api request from %s' % url
Where the url passed in to the function is the REST url as in the examples above. If you don't need to authenticate then simply modify the method to remove adding the Authorization header. You can then get any public api url using a simple GET request.