Export and analyze your GitHub activity across organizations.
Python GitHub License GitHub Stars linting - Ruff
01_get_activity.py— Fetches your GitHub activity via API and exports to CSV/JSON02_explore_activity.ipynb— Jupyter notebook for visualizing and analyzing the data
| Kind | Description |
|---|---|
commits |
Your commits (default branches) |
prs_opened |
PRs you created |
prs_merged |
PRs you merged |
prs_reviewed |
PRs you reviewed |
prs_commented |
PRs you commented on |
issues_opened |
Issues you created |
involves_me |
Issues/PRs involving you |
git clone https://github.com/rnckp/github-activity.git
cd github-activity
pip3 install uv
uv venv
uv sync-
Go to GitHub Settings → Developer settings → Personal access tokens → Tokens (classic)
-
Click "Generate new token"
-
Set name and expiration
-
Required permissions:
repo— Access repository datauser -> read:user— Read ALL user profile data
-
Copy the token
export GITHUB_TOKEN="github_pat_..."
# Default: rolling last 365 days, all orgs you're a member of uv run 01_get_activity.py # Custom date range uv run 01_get_activity.py --from 2025年01月01日 --to 2025年12月31日 # Specific organization(s) uv run 01_get_activity.py --org my-org --org another-org # Custom output prefix uv run 01_get_activity.py --out my_activity
Output: github_activity_YYYY-MM-DD_YYYY-MM-DD.csv and .json
Open 02_explore_activity.ipynb in Jupyter/VS Code. The notebook provides:
- Activity type distribution
- Top repositories by commits
- Monthly/weekly/hourly commit patterns
- Day-of-week heatmaps
- Commit message analysis
- Organization breakdown
| Issue | Solution |
|---|---|
ERROR: set GITHUB_TOKEN |
Export your token: export GITHUB_TOKEN="..." |
403 Forbidden |
Token lacks required permissions. Regenerate with read:org + repo |
404 Not Found on org |
You're not a member, or token doesn't have access to that org |
| Rate limit hit | Script auto-waits. For large exports, run during off-peak hours |
| Empty results | Check date range. Verify org membership with gh api /user/memberships/orgs |
| Missing commits | Only default branch commits are indexed by GitHub Search API |
Verify the token is being used and identify the login.
Run these two calls and ensure you get your expected username back:
curl -sS -H "Authorization: Bearer $GITHUB_TOKEN" \ -H "Accept: application/vnd.github+json" \ https://api.github.com/user | jq -r .login curl -i -sS -H "Authorization: Bearer $GITHUB_TOKEN" \ -H "Accept: application/vnd.github+json" \ https://api.github.com/rate_limit | head
If /user doesn’t return your login, the script will search for the wrong user and likely get zero hits.
Debug the org discovery (this is the most common "empty output" cause).
Try both endpoints manually:
# Membership objects (active/pending) for the authenticated user curl -sS -H "Authorization: Bearer $GITHUB_TOKEN" \ -H "Accept: application/vnd.github+json" \ "https://api.github.com/user/memberships/orgs?state=active&per_page=100" | jq '.[].organization.login' # Orgs for the authenticated user (often simpler) curl -sS -H "Authorization: Bearer $GITHUB_TOKEN" \ -H "Accept: application/vnd.github+json" \ "https://api.github.com/user/orgs?per_page=100" | jq '.[].login'
If these return empty lists, your token likely lacks read:org permission or you are not a member of any orgs.
For feedback or contributions open an issue or pull request.
I use ruff for linting and formatting.
This project is licensed under the MIT License. See the LICENSE file for details.