Skip to content

Instantly share code, notes, and snippets.

@navicore
Created March 23, 2023 13:25
Show Gist options
  • Save navicore/88b3766494d5f49d8cbabe3d06818a57 to your computer and use it in GitHub Desktop.
Save navicore/88b3766494d5f49d8cbabe3d06818a57 to your computer and use it in GitHub Desktop.
import requests
import json
import os
# Replace with your GitHub username and personal access token
username = 'navicore'
token = 'CHANGEME'
# API endpoint to fetch repositories sorted by updated_at in descending order
api_url = f'https://api.github.com/users/{username}/repos?sort=updated&direction=desc&per_page=25'
# Send a request to the GitHub API
response = requests.get(api_url, auth=(username, token))
if response.status_code == 200:
repos = json.loads(response.text)
for repo in repos:
ssh_url = repo['ssh_url']
repo_name = repo['name']
print(f'Cloning {repo_name}...')
os.system(f'gh repo clone {ssh_url}')
else:
print(f'Error: {response.status_code}')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment