A sleek, lightweight command-line tool built with Python to fetch and display GitHub user activity. Track any GitHub user's recent public activities with a simple command.
- Simple & Fast: Fetch user activity with a single command
- Comprehensive Activity Tracking: Displays pushes, issues, pull requests, forks, stars, and more
- File Export: Save activity data to a text file for later reference
- Error Handling: Robust input validation and helpful error messages
- Real-time Data: Fetches live data from GitHub API
- Multiple Event Types: Supports 12+ different GitHub event types
# Clone the repository
git clone https://github.com/oheyek/GitHub-User-Activity.git
cd GitHub-User-Activity
# Install dependencies
pip install -r requirements.txt
# Install as a CLI tool (optional)
pip install -e .After installation, you can use github-activity directly:
github-activity octocatAlternatively, run directly with Python:
python main.py octocat# Fetch activity for a GitHub user
github-activity <username>
# Examples
github-activity octocat
github-activity torvalds
github-activity gvanrossumThe tool will:
- Fetch the user's recent public activity from GitHub API
- Parse and format the activity into readable messages
- Save the activity to a text file named
<username>_activity.txt - Display a success message
The CLI tracks and displays the following GitHub activities:
| Event Type | Description | Example Output |
|---|---|---|
| PushEvent | Code commits pushed | "Pushed 3 commits to user/repo." |
| IssuesEvent | Issue creation/updates | "Opened an issue in user/repo." |
| PullRequestEvent | Pull request activities | "Opened a pull request #42 in user/repo." |
| ForkEvent | Repository forks | "Forked user/repo." |
| WatchEvent | Repository stars | "Starred user/repo." |
| CreateEvent | Branch/tag creation | "Created a new branch in user/repo." |
| DeleteEvent | Branch/tag deletion | "Deleted a branch in user/repo." |
| IssueCommentEvent | Issue comments | "Created a comment on issue #15 at user/repo." |
| PullRequestReviewEvent | PR reviews | "Submitted a review on pull request #23 in user/repo." |
| ReleaseEvent | Release management | "Published a release in user/repo." |
| GollumEvent | Wiki edits | "Edited the wiki in user/repo." |
| MemberEvent | Collaborator changes | "Added member username in user/repo." |
$ github-activity octocat
Activity saved to file successfully.Pushed 2 commits to octocat/Hello-World.
Starred microsoft/vscode.
Opened an issue in octocat/Spoon-Knife.
Forked rails/rails.
GitHub-User-Activity/
├── main.py # Main application logic
├── requirements.txt # Python dependencies
├── setup.py # Package setup configuration
└── README.md # This file
- Language: Python 3.8+
- API: GitHub REST API v3
- Dependencies: requests library
- Storage: Text file output
- Rate Limiting: Respects GitHub API rate limits
The CLI provides helpful error messages for common issues:
- User not found: "User {username} has not been found."
- API errors: "API error appeared: code {status_code}"
- Missing username: "Error: Invalid usage. Proper command format: github-activity "
- No activity: "The user has no public activity."
The tool handles various GitHub API response codes:
- 200: Success - processes and displays activity
- 404: User not found
- Other codes: API error with status code
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
# Check activity for different users
github-activity octocat
github-activity torvalds
github-activity gvanrossum
# Files are automatically created
ls *.txt
# octocat_activity.txt torvalds_activity.txt gvanrossum_activity.txt
# View saved activity
cat octocat_activity.txt$ github-activity octocat
Activity saved to file successfully.
$ cat octocat_activity.txt
Pushed 1 commits to octocat/Hello-World.
Starred rails/rails.
Opened an issue in octocat/Spoon-Knife.
Created a comment on issue #1 at octocat/Hello-World.
Forked microsoft/vscode.- Fetches the most recent 30 public events per user (GitHub API default)
- Minimal processing overhead
- Efficient text file output
- No persistent storage requirements
The CLI currently handles the most common GitHub event types. However, GitHub has additional event types that are less frequently used. If you encounter an event type that isn't supported, you can easily extend the functionality:
- Identify the missing event: Check the GitHub API documentation for event types
- Add to the events dictionary: In
main.py, add your event type to theeventsdictionary in thedetect_activity()function - Format the message: Create a descriptive message following the existing pattern
Example of adding a new event type:
"NewEventType": {
"message": f"Performed action in {repo_name}."
}Contributing: If you add support for additional event types, please consider contributing back to the project via a pull request to help other users!
This project is open source and available under the MIT License.
Happy GitHub Tracking! 🎉
If you find this project useful, consider buying me a coffee!
