A powerful command-line tool to fetch and display GitHub user activity with advanced filtering capabilities.
- Overview
- Features
- Installation
- Usage
- Filter Options
- Examples
- Technical Details
- Error Handling
- Contributing
- License
GitHub User Activity CLI is a lightweight Python tool that retrieves and displays recent activity from any GitHub user's public profile. The application fetches data directly from the GitHub REST API and presents it in a clean, human-readable format in your terminal.
Key Highlights:
- Zero external dependencies - uses only Python standard library
- Smart filtering system for precise activity tracking
- Human-readable time formatting ("2 hours ago")
- Professional error handling
- Clean, well-documented code
- π Activity Display: View commits, issues, PRs, stars, forks, and more
- π Advanced Filtering: Filter by event type, repository name, or date range
- β° Time Intelligence: See when events occurred with relative timestamps
- π― Precision Control: Limit results and combine multiple filters
- π‘οΈ Robust Error Handling: Gracefully handles network issues and invalid inputs
- π Fast & Lightweight: No external dependencies, instant execution
- Python 3.6 or higher
- Internet connection
-
Download the script:
# Clone the repository git clone https://github.com/yourusername/github-activity-cli.git cd github-activity-cli
-
Make it executable (optional):
chmod +x github_activity.py
-
Run it:
python github_activity.py <username>
That's it! No pip install, no virtual environment needed.
python github_activity.py <username> [options]python github_activity.py kamranahmedseOutput:
Fetching activity for GitHub user: kamranahmedse...
Recent Activity (30 events)
------------------------------------------------------------
- Pushed 3 commit(s) to kamranahmedse/developer-roadmap
- Opened an issue in kamranahmedse/developer-roadmap
- Starred torvalds/linux
- Forked facebook/react
- Created branch in kamranahmedse/roadmap
...
| Option | Short | Description | Example |
|---|---|---|---|
--type |
-t |
Filter by event type | --type push |
--repo |
-r |
Filter by repository name | --repo react |
--limit |
-l |
Limit number of results | --limit 10 |
--date |
-d |
Show events after date | --date 2024-01-01 |
--today |
Show only today's events | --today |
|
--week |
Show events from last 7 days | --week |
| Type | Description | Usage |
|---|---|---|
push |
Code commits | --type push |
create |
Branch/repo creation | --type create |
delete |
Branch deletion | --type delete |
issues |
Issue activity | --type issues |
issue_comment |
Issue comments | --type issue_comment |
star / watch |
Starred repositories | --type star |
fork |
Forked repositories | --type fork |
pr / pull_request |
Pull requests | --type pr |
pr_review |
PR reviews | --type pr_review |
pr_comment |
PR comments | --type pr_comment |
release |
New releases | --type release |
member |
Collaborator additions | --type member |
# View all activity for a user
python github_activity.py torvalds
# View activity with limited results
python github_activity.py gaearon --limit 10# Show only push events (commits)
python github_activity.py kamranahmedse --type push
# Show only starred repositories
python github_activity.py kentcdodds --type star
# Show only pull request activity
python github_activity.py facebook --type pr# Show activity in a specific repository
python github_activity.py facebook --repo react
# Show push events in a specific repo
python github_activity.py microsoft --repo vscode --type push# Show events from a specific date
python github_activity.py kamranahmedse --date 2024-01-01
# Show only today's activity
python github_activity.py nodejs --today
# Show activity from the last week
python github_activity.py rust-lang --week# Push events in a specific repo, limited to 5
python github_activity.py kamranahmedse --type push --repo roadmap --limit 5
# Issues from the last week, limited to 10
python github_activity.py facebook --type issues --week --limit 10
# All activity in a repo from a specific date
python github_activity.py torvalds --repo linux --date 2024-10-01The application is built with a modular architecture:
fetch_user_activity(): Handles API requests to GitHubfilter_events(): Applies user-specified filters to eventsformat_event(): Converts raw event data to readable stringsparse_arguments(): Processes command-line argumentsdisplay_activity(): Presents formatted results to the user
GET https://api.github.com/users/{username}/events
The application uses GitHub's public REST API v3, which provides the 30 most recent public events for any user.
- Events are returned as JSON arrays
- Each event contains:
type,repo,payload,created_at - No authentication required for public data
- Rate limit: 60 requests per hour for unauthenticated requests
User Input β Parse Arguments β Fetch from GitHub API β Parse JSON β
Filter Events β Format Output β Display in Terminal
The application handles various error scenarios:
| Error Type | Handling |
|---|---|
| User not found | Displays "User not found" message |
| Network issues | Reports connection error with details |
| Invalid JSON | Catches parsing errors gracefully |
| Missing arguments | Shows usage instructions |
| Invalid filters | Warns and ignores invalid options |
Example Error Output:
$ python github_activity.py nonexistentuser123
Fetching activity for GitHub user: nonexistentuser123...
Error: User 'nonexistentuser123' not found.This project demonstrates proficiency in:
- API Integration: Making HTTP requests and handling responses
- Data Processing: Parsing and transforming JSON data
- CLI Development: Building user-friendly command-line interfaces
- Error Handling: Implementing robust exception handling
- Filtering Logic: Creating complex data filtering systems
- Code Organization: Writing clean, modular, maintainable code
- Documentation: Providing clear usage instructions
# Linux kernel maintainer
python github_activity.py torvalds
# React core team
python github_activity.py gaearon
# Node.js organization
python github_activity.py nodejs# Non-existent user
python github_activity.py thisuserdoesnotexist12345python github_activity.py
- Python: 3.6 or higher
- Libraries:
urllib,json,sys,datetime(all built-in) - Network: Internet connection required
- API: GitHub REST API v3 (no authentication needed for public data)
This project is inspired by the roadmap.sh GitHub User Activity project, designed to help developers practice:
- Working with external APIs
- Processing JSON data
- Building CLI applications
- Implementing filtering logic
- Error handling and validation
- GitHub for providing an excellent public API
- The Python community for great documentation
- roadmap.sh for project inspiration
- Issues: GitHub Issues
- Discussions: GitHub Discussions
Made with β€οΈ and Python