Skip to Content
Made with đź–¤ by @1chooo
API Documentation

API Documentation

GitHub Users API

Get comprehensive GitHub user statistics and information.

Endpoint

GET /api/github/users

Description

This endpoint fetches detailed GitHub user information including profile data, repository statistics, followers, and top repositories. It aggregates data from multiple GitHub API endpoints to provide a comprehensive overview of a GitHub user’s activity and statistics.

Parameters

Query Parameters

ParameterTypeRequiredDefaultDescription
user_namestringNoConfig default usernameGitHub username to fetch data for

Request Examples

Get default user (from config)

curl -X GET "https://1chooo.com/api/github/users"

Get specific user

curl -X GET "https://1chooo.com/api/github/users?user_name=octocat"

Response

Success Response (200)

{ "user": { "login": "octocat", "name": "The Octocat", "bio": "A great octopus masquerading as a cat", "location": "San Francisco", "company": "@github", "blog": "https://github.blog", "avatar_url": "https://github.com/images/error/octocat_happy.gif", "html_url": "https://github.com/octocat", "public_repos": 8, "followers": 4000, "following": 9, "created_at": "2011-01-25T18:44:36Z", "updated_at": "2022-07-09T09:23:27Z" }, "stats": { "totalStars": 150, "totalForks": 45, "totalIssues": 23, "totalPRs": 67, "publicRepos": 8, "totalRepos": 8, "followersCount": 4000, "followingCount": 9 }, "followers": [ { "login": "defunkt", "id": 2, "avatar_url": "https://github.com/images/error/defunkt_happy.gif", "html_url": "https://github.com/defunkt", "type": "User" } ], "topRepos": [ { "name": "Hello-World", "full_name": "octocat/Hello-World", "description": "This your first repo!", "html_url": "https://github.com/octocat/Hello-World", "stargazers_count": 80, "forks_count": 9, "language": "C", "updated_at": "2011-01-26T19:06:43Z", "topics": ["octocat", "atom", "electron", "api"] } ] }

Response Schema

User Object

FieldTypeDescription
loginstringGitHub username
namestringDisplay name
biostringUser bio
locationstringUser location
companystringCompany name
blogstringBlog/website URL
avatar_urlstringProfile picture URL
html_urlstringGitHub profile URL
public_reposnumberNumber of public repositories
followersnumberNumber of followers
followingnumberNumber of following
created_atstringAccount creation date (ISO 8601)
updated_atstringLast profile update date (ISO 8601)

Stats Object

FieldTypeDescription
totalStarsnumberTotal stars across all non-fork repositories
totalForksnumberTotal forks across all repositories
totalIssuesnumberTotal issues created by the user
totalPRsnumberTotal pull requests created by the user
publicReposnumberNumber of public repositories
totalReposnumberTotal number of repositories
followersCountnumberNumber of followers
followingCountnumberNumber of users following

Followers Array

Array of follower objects with:

FieldTypeDescription
loginstringFollower’s username
idnumberFollower’s GitHub ID
avatar_urlstringFollower’s profile picture URL
html_urlstringFollower’s GitHub profile URL
typestringAccount type (User, Organization)

Top Repos Array

Array of top 10 repositories (by stars) with:

FieldTypeDescription
namestringRepository name
full_namestringFull repository name (owner/repo)
descriptionstringRepository description
html_urlstringRepository URL
stargazers_countnumberNumber of stars
forks_countnumberNumber of forks
languagestringPrimary programming language
updated_atstringLast update date (ISO 8601)
topicsarrayRepository topics/tags

Error Responses

User Not Found (404)

{ "error": "User not found" }

Rate Limited (403)

{ "error": "API rate limit exceeded or access forbidden" }

Server Error (500)

{ "error": "Failed to fetch GitHub data", "details": "Specific error message" }

Rate Limiting

This endpoint uses the GitHub API which has rate limiting:

  • Unauthenticated requests: 60 requests per hour per IP
  • Authenticated requests: 5,000 requests per hour

The endpoint makes multiple GitHub API calls:

  • 1 call to fetch user profile
  • 1 call to fetch repositories
  • 1 call to fetch followers
  • 2 calls to search for issues and PRs

Total: ~5 API calls per request

Implementation Notes

  • Fork repositories are excluded from star counts
  • Only public repositories are included in statistics
  • Top repositories are sorted by star count (descending)
  • Issues and PR counts are fetched separately and may fail gracefully
  • Response includes comprehensive error handling for common GitHub API errors
  • All repository data is filtered to include only relevant fields

Dependencies

  • octokit: GitHub API client
  • @/config: Application configuration for default username

Authentication

Currently operates without authentication. For higher rate limits, add GitHub token to the Octokit configuration.

GitHub Repositories API

Get GitHub repository information - either a specific repository or all repositories for a user.

Endpoint

GET /api/github/repos

Description

This endpoint fetches GitHub repository data. It can operate in two modes:

  1. Single Repository Mode: Fetch specific repository statistics when repo_name is provided
  2. All Repositories Mode: Fetch all repositories for the configured user when no repo_name is provided

Parameters

Query Parameters

ParameterTypeRequiredDefaultDescription
repo_namestringNo-Specific repository name to fetch. If omitted, returns all repositories

Request Examples

Get all repositories

curl -X GET "https://1chooo.com/api/github/repos"

Get specific repository

curl -X GET "https://1chooo.com/api/github/repos?repo_name=portfolio"

Response

Single Repository Response (200)

When repo_name parameter is provided:

{ "stars": 42, "forksCount": 7 }

All Repositories Response (200)

When no repo_name parameter is provided:

{ "repos": [ { "name": "portfolio", "fullName": "username/portfolio", "description": "My personal portfolio website built with Next.js", "stars": 42, "forksCount": 7, "language": "TypeScript", "url": "https://github.com/username/portfolio", "updatedAt": "2025-07-07T10:30:00Z", "isPrivate": false }, { "name": "awesome-project", "fullName": "username/awesome-project", "description": "An awesome open source project", "stars": 128, "forksCount": 23, "language": "JavaScript", "url": "https://github.com/username/awesome-project", "updatedAt": "2025-07-06T14:22:15Z", "isPrivate": false } ], "totalCount": 2 }

Response Schema

Single Repository Mode

FieldTypeDescription
starsnumberNumber of stars the repository has received
forksCountnumberNumber of times the repository has been forked

All Repositories Mode

FieldTypeDescription
reposarrayArray of repository objects
totalCountnumberTotal number of repositories returned

Repository Object

FieldTypeDescription
namestringRepository name
fullNamestringFull repository name (owner/repo)
descriptionstringRepository description
starsnumberNumber of stargazers
forksCountnumberNumber of forks
languagestringPrimary programming language
urlstringRepository HTML URL
updatedAtstringLast update timestamp (ISO 8601)
isPrivatebooleanWhether the repository is private

Error Responses

Repository Not Found (404)

When a specific repository is requested but doesn’t exist:

{ "error": "Repository not found" }

User Not Found (404)

When fetching all repositories but the user doesn’t exist:

{ "error": "User not found" }

Repository Fetch Error (500)

When there’s an error fetching a specific repository:

{ "error": "Failed to fetch repository", "details": "Specific error message from GitHub API" }

Repositories Fetch Error (500)

When there’s an error fetching all repositories:

{ "error": "Failed to fetch repositories", "details": "Specific error message from GitHub API" }

Internal Server Error (500)

General server error:

{ "error": "Internal server error", "details": "Specific error message" }

Rate Limiting

This endpoint uses the GitHub API which has rate limiting:

  • Unauthenticated requests: 60 requests per hour per IP
  • Authenticated requests: 5,000 requests per hour

API Calls Per Request

  • Single Repository Mode: 1 GitHub API call
  • All Repositories Mode: 1 GitHub API call

Usage Examples

Frontend Integration

// Get all repositories const getAllRepos = async () => { try { const response = await fetch("/api/github/repos"); const data = await response.json(); if (response.ok) { console.log(`Found ${data.totalCount} repositories`); data.repos.forEach((repo) => { console.log(`${repo.name}: ${repo.stars} stars`); }); } else { console.error("Error:", data.error); } } catch (error) { console.error("Fetch error:", error); } }; // Get specific repository const getRepoStats = async (repoName) => { try { const response = await fetch(`/api/github/repos?repo_name=${repoName}`); const data = await response.json(); if (response.ok) { console.log(`${repoName}: ${data.stars} stars, ${data.forksCount} forks`); } else { console.error("Error:", data.error); } } catch (error) { console.error("Fetch error:", error); } };

cURL Examples

# Get all repositories with verbose output curl -v -X GET "https://1chooo.com/api/github/repos" # Get specific repository with error handling curl -X GET "https://1chooo.com/api/github/repos?repo_name=nonexistent" \ -w "HTTP Status: %{http_code}\n" # Get repositories and save to file curl -X GET "https://1chooo.com/api/github/repos" \ -H "Accept: application/json" \ -o repositories.json

Implementation Notes

Data Processing

  • All Repositories Mode: Fetches up to 100 repositories, sorted by last updated
  • Repository Filtering: Includes both public and private repositories (if accessible)
  • Data Transformation: GitHub API response is transformed to provide cleaner field names

Error Handling

  • Specific error handling for 404 (not found) scenarios
  • Separate error paths for single repository vs. all repositories modes
  • Detailed error messages include original GitHub API error details

Configuration

  • Uses config.about.githubUsername as the default repository owner
  • GitHub API version is pinned to 2022-11-28 for consistency

Authentication

Currently operates without authentication. For accessing private repositories or higher rate limits, add a GitHub token to the Octokit configuration:

const octokit = new Octokit({ auth: process.env.GITHUB_TOKEN, });

Dependencies

  • octokit: GitHub API client library
  • @/config: Application configuration for default username
  • next: Next.js framework for request/response handling
Last updated on