Skip to content

About

📊 GitHub commit counter using GraphQL API

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

 

History

43 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

📊 GitHub Commit Counter

Counts the total number of commits made by a GitHub user in a specified year using the GitHub GraphQL API.

🎯 Features

  • 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

🛠️ Installation

git clone https://github.com/FelineFantasy/GitHub-Commit-Counter
cd GitHub-Commit-Counter
pip install -r requirements.txt
python main.py

Requirements

  • Python 3.6+
  • requests library
  • GitHub Personal Access Token (see setup below)

🚀 Usage

Run the script without arguments to answer the prompts:

python main.py

Pass the username and year to skip them:

python main.py FelineFantasy 2026

Add --json to get machine-readable output for scripts:

python main.py FelineFantasy 2026 --json
# {"username": "FelineFantasy", "year": 2026, "commits": 161}

The script exits with status 0 on success and 1 when the arguments are invalid or the data cannot be fetched.

Setting up a GitHub Token

  1. Go to GitHub Settings → Developer settings → Personal access tokens → Tokens (classic)
  2. Click "Generate new token (classic)"
  3. Give it a name and select the repo scope (or public_repo for public repositories only)
  4. Generate and copy your token

Interactive Input

If you leave out the username or the year, the script will prompt you for the missing value:

  1. GitHub username - The user whose commits you want to count
  2. Year - The year to check (e.g., 2026)
  3. GitHub token - Your personal access token (input will be hidden for security)

📝 Example Output

Введите GitHub username: FelineFantasy
Введите год (например, 2026): 2026
Введите GitHub токен: ghp_xxxxxxxxxxxxxxxxxxxx

Всего коммитов за 2026: 161

⚠️ Notes

  • 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

🛠 Technical Details

  • Uses GitHub's official GraphQL API endpoint
  • Queries contributionsCollection for accurate commit counting
  • Handles date ranges automatically for the full year

❗ Common Issues

  • 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

✅ Running Tests

The test suite uses only the standard library's unittest:

python -m unittest discover -s tests -t . -v

💖 Support the Project

If you enjoy GitHub-Commit-Counter and want to help keep the project alive, you can support me here:

DonationAlerts

Your support helps me:

  • 🐱 Keep developing new tools
  • 🛠️ Fix bugs and improve accuracy
  • ☕ Stay awake while coding at 4 AM

Every little bit is appreciated! ❤️

👤 Author

  • FelineFantasy
  • License: MIT

About

📊 GitHub commit counter using GraphQL API

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Sponsor this project

Packages

Contributors

Languages