Counts the total number of commits made by a GitHub user in a specified year using the GitHub GraphQL API.
- Asks for a GitHub username, a year, and a personal access token
- Uses GitHub's GraphQL API for fast and reliable data retrieval
- Displays the total number of commits for the specified year
pip install -r requirements.txt- Python 3.6+
requestslibrary- GitHub Personal Access Token (see setup below)
- Go to GitHub Settings → Developer settings → Personal access tokens → Tokens (classic)
- Click "Generate new token (classic)"
- Give it a name and select the
reposcope (orpublic_repofor public repositories only) - Generate and copy your token
python github_commit_counter.pyThe script will prompt you for:
- GitHub username - The user whose commits you want to count
- Year - The year to check (e.g., 2026)
- GitHub token - Your personal access token (input will be hidden for security)
Введите GitHub username: FelineFantasy
Введите год (например, 2026): 2026
Введите GitHub токен: ghp_xxxxxxxxxxxxxxxxxxxx
Всего коммитов за 2026: 161
- A GitHub token is required to use the GitHub GraphQL API
- Rate limits apply based on your token type:
- Unauthenticated: 60 requests/hour (not used in this script)
- Authenticated: 5,000 requests/hour
- The token does not need to be stored in the code; it's entered at runtime
- Uses GitHub's official GraphQL API endpoint
- Queries
contributionsCollectionfor accurate commit counting - Handles date ranges automatically for the full year
- Invalid token: Ensure your token has the correct permissions
- Rate limiting: If you hit the limit, wait an hour and try again
- User not found: Verify the username is spelled correctly
- FelineFantasy
- License: MIT