github-stats-api-go
is a Go-based API that retrieves statistics from GitHub for a specified user. It provides information such as the number of followers, repositories, stars, and organizations associated with the user.
- Retrieve user statistics from GitHub
- Includes options for fetching stars, followers, following, repositories, and organizations
- Simple HTTP/HTTPS server to handle requests
To use this API, you need to have Go installed on your machine. You can install it from the official Go website.
- Initialize a new Go module:
go mod init your_project_name
- Install the module using
go get
:
go get github.com/SUP2Ak/github-stats-api-go
- Create a new Go file (e.g.,
main.go
) and import the module:
package main
import (
"log"
"time"
githubstats "github.com/sup2ak/github-stats-api-go"
)
func main() {
// Configuration
config := githubstats.Config{
Token: "your_github_token",
IP: "0.0.0.0",
Port: "8080",
Scheme: "http", // or "https" null value is "http"
Path: "/stats",
RateLimit: 10,
CacheDuration: 1 * time.Hour,
// and more...
}
// Create an instance of GStats
stats := githubstats.GStats{}
// Connect to the GitHub API
err := stats.Connect(config)
if err != nil {
log.Fatalf("Connection error: %v", err)
}
}
- Run the program:
go run main.go
To get statistics for the user sup2ak
, you can make a GET request:
curl "http://localhost:8080/stats?username=sup2ak"
This project is licensed under the GPL-3.0 License.
Contributions are welcome! Please open an issue or submit a pull request for any improvements or bug fixes.