🚀 gh-proxy API Documentation

gh-proxy is a GitHub API proxy that provides rate limiting, caching, and token pooling for GitHub API requests.

⚠️ API Key Required: All API requests require a valid API key. Contact an administrator to get one.

📋 Quick Start

Base URL

https://gh-proxy.hackclub.com

Authentication

Include your API key in the X-API-Key header:

curl -H "X-API-Key: your_api_key_here" https://gh-proxy.hackclub.com/gh/user

🔗 Available Endpoints

GET /gh/{path}

Description: Proxy any GitHub REST API endpoint

Example:

# Get current user
curl -H "X-API-Key: your_key" https://gh-proxy.hackclub.com/gh/user

# Get repository information
curl -H "X-API-Key: your_key" https://gh-proxy.hackclub.com/gh/repos/octocat/Hello-World

# List user repositories
curl -H "X-API-Key: your_key" https://gh-proxy.hackclub.com/gh/users/octocat/repos

# Search repositories
curl -H "X-API-Key: your_key" "https://gh-proxy.hackclub.com/gh/search/repositories?q=javascript"

POST /gh/graphql

Description: Proxy GitHub GraphQL API

Content-Type: application/json

Example:

# GraphQL query
curl -X POST \
  -H "X-API-Key: your_key" \
  -H "Content-Type: application/json" \
  -d '{"query": "query { viewer { login name } }"}' \
  https://gh-proxy.hackclub.com/gh/graphql

⚡ Rate Limiting

Each API key has its own rate limit (configurable per key, default: 10 requests/second).

Rate Limit Exceeded: Returns 429 Too Many Requests when limit is exceeded.

🗄️ Caching

Responses are automatically cached to improve performance:

Cache Hit: X-Gh-Proxy-Cache: hit means the response came from cache

Cache Miss: X-Gh-Proxy-Cache: miss means a fresh request was made to GitHub

📊 Response Headers

The proxy adds helpful debug headers to responses:

🔧 JavaScript/Node.js Examples

Using fetch()

const response = await fetch('https://gh-proxy.hackclub.com/gh/user', {
  headers: {
    'X-API-Key': 'your_api_key_here'
  }
});
const user = await response.json();
console.log(user);

Using axios

const axios = require('axios');

const api = axios.create({
  baseURL: 'https://gh-proxy.hackclub.com/gh',
  headers: {
    'X-API-Key': 'your_api_key_here'
  }
});

// Get user info
const user = await api.get('/user');

// GraphQL query
const graphql = await api.post('/graphql', {
  query: 'query { viewer { login repositories(first: 10) { nodes { name } } } }'
});

🐍 Python Example

import requests

headers = {'X-API-Key': 'your_api_key_here'}

# REST API
response = requests.get('https://gh-proxy.hackclub.com/gh/user', headers=headers)
user = response.json()

# GraphQL
graphql_query = {
    "query": "query { viewer { login name } }"
}
response = requests.post('https://gh-proxy.hackclub.com/gh/graphql', 
                        headers=headers, 
                        json=graphql_query)
data = response.json()

⚠️ Error Responses

💡 Tips & Best Practices

📞 Support

For API keys or technical support, contact your system administrator.