A simple command-line tool to fetch and display a GitHub user's recent activity using the GitHub API. This project helps you practice working with APIs, handling JSON data, and building a CLI in Go.
- Fetches and displays the recent activity of a GitHub user in the terminal.
- CLI accepts the GitHub username as an argument.
- Handles errors gracefully, including invalid usernames or API failures.
- (Optional) Caching mechanism to improve performance.
- Go 1.18+
- GitHub API token (if needed for higher rate limits)
-
Clone the repository:
git clone https://github.com/<your-username>/github-activity-cli.git cd github-activity-cli
-
Install the necessary dependencies:
go mod tidy
-
Build the CLI tool:
go build -o github-activity ./cmd/github-activity
-
Run the tool by passing a GitHub username as an argument:
./github-activity <username>
Example:
./github-activity kamranahmedse
This will display the recent public activity of the specified user, like:
- Pushed 3 commits to kamranahmedse/developer-roadmap - Opened a new issue in kamranahmedse/developer-roadmap - Starred kamranahmedse/developer-roadmap
The tool will gracefully handle common errors like:
- Invalid GitHub usernames
- Network issues or GitHub API failures
- Rate-limiting by the GitHub API
In case of errors, appropriate messages will be displayed in the terminal.
You can enable caching to store the fetched activity data temporarily, reducing redundant API calls for the same user.
github-activity-cli/
├── cmd/
│ └── github-activity/
│ └── main.go # CLI entry point
├── internal/
│ ├── api/
│ │ └── github.go # GitHub API requests
│ └── model/
│ └── event.go # Data model for GitHub events
├── pkg/
│ └── cli/
│ └── cli.go # CLI utilities or reusable logic
├── go.mod # Go module dependencies
├── go.sum # Go module checksums
└── README.md # Project documentation
This tool uses the following GitHub API endpoint to fetch user activity:
GET https://api.github.com/users/<username>/events
For more details on the GitHub API, see the official documentation.
- Filtering by event type: Filter events such as push, issue creation, starring, etc.
- Structured output: Display activity in a more organized or structured format.
- Additional API endpoints: Fetch more user-related data, like repositories, followers, etc.