Git Wrapped API

repository·main·Indexed 23 days ago

https://github.com/gabriel-pineda/git-wrapped-api

An 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.

Tokens
918
Snippets
4
Records
8
Agent score
80%

What's inside git-wrapped-api

  1. Retrieve GitHub activity statistics via GET /api/stats

    main

    The /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:

    • An environment variable GITHUB_TOKEN must be configured for authentication via Octokit.
    • The endpoint runs on the 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.
  2. Fetch GitHub stats via /api/stats

    main

    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}`)
  3. GitHubStats response data format

    main

    A successful request to the /api/stats endpoint returns a GitHubStats object with the following structure:

    FieldTypeDescription
    longestStreaknumberThe maximum consecutive days with contributions.
    totalCommitsnumberTotal number of contributions.
    commitRankstringAn approximate percentile rank based on total commits (e.g., "Top 1%-3%").
    calendarDataContributionDay[]Array of daily contribution objects.
    mostActiveDayobjectContains name (weekday string) and commits (average commits).
    mostActiveMonthobjectContains name (month string) and commits (total commits for that month).
    starsEarnednumberTotal stargazer count across the user's top 100 repositories.
    topLanguagesstring[]An array of the top 3 primary programming languages used in the user's repositories.

    ContributionDay Object:

    • contributionCount: number
    • date: string (ISO format)
    • weekday: number (0-6, where 0 is Sunday)