Skip to content

Instantly share code, notes, and snippets.

@vldmrdev
Last active March 24, 2025 02:05
Show Gist options
  • Save vldmrdev/49226e4181ccb32f90922daa20ccd69f to your computer and use it in GitHub Desktop.
Save vldmrdev/49226e4181ccb32f90922daa20ccd69f to your computer and use it in GitHub Desktop.
How to get github project's ID
import requests

GITHUB_TOKEN = 'GitHub personal access token'  # Your GitHub personal access token
REPO_OWNER = 'username'  # The GitHub username/organization
REPO_NAME = 'repo-name'  # The repository name

url = f'https://api.github.com/repos/{REPO_OWNER}/{REPO_NAME}'

headers = {
    'Authorization': f'token {GITHUB_TOKEN}'
}

response = requests.get(url, headers=headers)

if response.status_code == 200:
    repo_data = response.json()
    print(f"Repository ID: {repo_data['id']}")
else:
    print(f"Failed to fetch repository details. Status code: {response.status_code}")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment