Skip to content Skip to sidebar Skip to footer

How To Get All Repositories Of A Specific Github User

How to get all repositories (> 100) of a specific GitHub user using a simple HTTP library like urllib2 or requests.

Solution 1:

To get more than 100 repositories from GitHub it's necessary to follow the links inside the link header.

import requests

def get_repositories(url):
    result = []
    r = requests.get(url=url)
    if 'next' in r.links :
        result += get_repositories(r.links['next']['url'])

    for repository in r.json():
        result.append(repository.get('name'))

    return result

url = "https://api.github.com/users/stackforge/repos"
print get_repositories(url)

Post a Comment for "How To Get All Repositories Of A Specific Github User"