Skip to content

Instantly share code, notes, and snippets.

@Haste171
Created March 5, 2024 01:26
Show Gist options
  • Save Haste171/c6b342aa8470acb2700593632e6298ba to your computer and use it in GitHub Desktop.
Save Haste171/c6b342aa8470acb2700593632e6298ba to your computer and use it in GitHub Desktop.
View all of you're lifetime pull requests across all of GitHub
import requests
import json
# Replace 'your_token_here' with your GitHub Personal Access Token
TOKEN = 'your_token_here'
# Replace 'your_username_here' with your GitHub username
USERNAME = 'haste171'
def get_merged_pull_requests(username, token):
headers = {'Authorization': f'token {token}'}
query = f'is:pr is:merged author:{username}'
url = f'https://api.github.com/search/issues?q={query}&per_page=200' # Adjust per_page as needed
response = requests.get(url, headers=headers)
if response.status_code == 200:
items = response.json().get('items', [])
for item in items:
pr_info = {
'title': item['title'],
'html_url': item['html_url'],
'created_at': item['created_at'],
'closed_at': item['closed_at'],
'repository_url': item['repository_url']
}
print(json.dumps(pr_info, indent=4))
else:
print(f"Failed to fetch data: {response.status_code}")
get_merged_pull_requests(USERNAME, TOKEN)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment