Skip to content

Instantly share code, notes, and snippets.


cmgeuze/ Secret

Created May 1, 2020
What would you like to do?
Python script to download repositories
from github import Github
import pygit2, os, time
ACCESS_TOKEN = '<your Github access token>'
g = Github(ACCESS_TOKEN)
def search_github(keywords):
rate_limit = g.get_rate_limit()
rate =
if rate.remaining == 0:
print(f'You have 0/{rate.limit} API calls remaining. Reset time: {rate.reset}')
print(f'You have {rate.remaining}/{rate.limit} API calls remaining')
query = '+'.join(keywords) + '+in:readme+in:description'
result = g.search_repositories(query, 'stars', 'desc')
print(f'Found {result.totalCount} repo(s)')
for repo in result:
time.sleep(0.1) #prevent rate limit
print(f'{repo.clone_url}, {repo.stargazers_count} stars')
if not os.path.exists("<local folder>" +
pygit2.clone_repository(repo.clone_url, "<local folder>" +
if __name__ == '__main__':
keywords = ['delphi']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment