Install Git Wrapped API
mainInstall the project dependencies using either yarn or npm.
# Using yarn
yarn install
# Using npm
npm installrepository·main·Indexed 23 days ago
https://github.com/gabriel-pineda/git-wrapped-apiAn API powering git-wrapped.com that generates visual representations of GitHub activity. It provides a /api/stats endpoint to retrieve user statistics, including total commits, longest streaks, commit rank, most active days/months, stars earned, and top programming languages using a GitHub Personal Access Token.
Install the project dependencies using either yarn or npm.
# Using yarn
yarn install
# Using npm
npm installStart the development server to run the application locally. Once running, the application will be available at http://localhost:3000.
# Using yarn
yarn dev
# Using npm
npm run devTo authenticate with GitHub, create a .env.local file in the root directory of the project and add your GitHub Personal Access Token using the GITHUB_TOKEN key.
GITHUB_TOKEN=ghp_<your_token_here>Before setting up the Git Wrapped API, ensure you have the following:
public_reporead:userThe /api/stats endpoint fetches and processes a user's GitHub activity. It requires a username query parameter and returns a JSON object containing contribution data, commit patterns, repository stars, and top programming languages.
Requirements:
GITHUB_TOKEN must be configured for authentication via Octokit.edge runtime.Query Parameter:
username (string): The GitHub login handle of the user to query.Error Responses:
400 Bad Request: Returned if the username parameter is missing.500 Internal Server Error: Returned if the GitHub API request fails or an error occurs during processing.The application provides a web interface to retrieve GitHub user statistics. You can programmatically or manually access these statistics by making a GET request to the /api/stats endpoint with a username query parameter.
Endpoint: /api/stats
Method: GET
Query Parameters:
username (string, required): The GitHub username for which to retrieve statistics.Response Format:
Returns a JSON object containing the user's statistics. If the request fails (e.g., user not found), the API returns an error object with an error field.
fetch(`/api/stats?username=${username}`)The commitRank field is determined by the following approximate thresholds based on totalCommits:
5000+: "Top 0.5%-1%"2000+: "Top 1%-3%"1000+: "Top 5%-10%"500+: "Top 10%-15%"200+: "Top 25%-30%"50+: "Median 50%"< 50: "Bottom 30%"A successful request to the /api/stats endpoint returns a GitHubStats object with the following structure:
| Field | Type | Description |
|---|---|---|
longestStreak | number | The maximum consecutive days with contributions. |
totalCommits | number | Total number of contributions. |
commitRank | string | An approximate percentile rank based on total commits (e.g., "Top 1%-3%"). |
calendarData | ContributionDay[] | Array of daily contribution objects. |
mostActiveDay | object | Contains name (weekday string) and commits (average commits). |
mostActiveMonth | object | Contains name (month string) and commits (total commits for that month). |
starsEarned | number | Total stargazer count across the user's top 100 repositories. |
topLanguages | string[] | An array of the top 3 primary programming languages used in the user's repositories. |
ContributionDay Object:
contributionCount: numberdate: string (ISO format)weekday: number (0-6, where 0 is Sunday)