Introduction
The Better Hub API provides programmatic access to GitHub data with enhanced features like AI-powered chat, semantic search, and workflow management. The API is built on Next.js App Router and uses session-based authentication.Base URL
Response Format
All API responses are returned in JSON format. Successful responses return the requested data directly, while errors follow this structure:Human-readable error message
Additional error details (for validation errors)
Example Success Response
Example Error Response
Rate Limiting
Better Hub implements rate limiting on sensitive endpoints:- PAT Sign-in: 5 requests per minute per IP
- AI endpoints: Subject to credit limits and usage tracking
- GitHub API: Inherits GitHub’s rate limits based on your authentication
429 Too Many Requests status.
API rate limits are separate from GitHub’s rate limits. GitHub API calls made through Better Hub use your GitHub OAuth token and count against your GitHub rate limit.
API Categories
The Better Hub API is organized into the following categories:Authentication
Session-based auth with GitHub OAuth and Personal Access Tokens
User Management
User profiles, settings, and preferences
GET /api/user-profileGET /api/user-settingsPATCH /api/user-settingsGET /api/user-scopes
GitHub Data
Search and retrieve GitHub repositories, issues, PRs, and users
GET /api/search-reposGET /api/search-issuesGET /api/search-prsGET /api/search-usersGET /api/search-codeGET /api/user-reposGET /api/org-repos
Repository Files
Access repository files and code
GET /api/file-contentGET /api/repo-filesGET /api/highlight-code
Workflows & Actions
GitHub Actions workflow runs and logs
GET /api/workflow-runsGET /api/job-logsGET /api/check-status
AI Features
AI-powered chat, commit messages, and code assistance
POST /api/ai/ghost- AI chat with GitHub contextPOST /api/ai/commit-message- Generate commit messagesPOST /api/ai/command- Execute AI commandsGET /api/ai/chat-history- Retrieve chat history
Billing & Credits
Credit balance and spending limits
GET /api/billing/balanceGET /api/billing/spending-limitPATCH /api/billing/spending-limitPOST /api/billing/welcome
Utilities
Helper endpoints for images, merge conflicts, and uploads
GET /api/github-imageGET /api/merge-conflictsPOST /api/uploadGET /api/rate-limit
Authentication Required
Most API endpoints require authentication. See the Authentication guide for details on:- GitHub OAuth flow
- Personal Access Token (PAT) sign-in
- Session management
- Using sessions in API requests
Unauthenticated requests will receive a
401 Unauthorized response.CORS & Security
The API is configured with trusted origins:https://www.better-hub.com(production)https://beta.better-hub.com(beta environment)https://better-hub-*-better-auth.vercel.app(Vercel previews)
Common Query Parameters
Many search and list endpoints support these query parameters:Page number for pagination
Number of results per page (max: 100)
Search query string
Sort field (varies by endpoint)
Sort order:
asc or descNext Steps
Authentication
Learn how to authenticate API requests
GitHub Integration
Explore GitHub data endpoints
AI Features
Use AI-powered features
Example Apps
Build with the Better Hub API