--- import BaseLayout from "@/layouts/BaseLayout.astro"; import { Code2, Webhook, Key, BookOpen } from "lucide-react"; const apiSections = [ { icon: Code2, title: "REST API", description: "Complete REST API reference for repositories, pull requests, and more", href: "/docs/api/rest-api", status: "Available", statusColor: "text-green-400" }, { icon: Webhook, title: "Webhooks", description: "Event-driven integrations with webhook payloads", href: "/docs/api/webhooks", status: "Available", statusColor: "text-green-400" }, { icon: Key, title: "Authentication", description: "API tokens, OAuth, and authentication flows", href: "/docs/api/authentication", status: "Available", statusColor: "text-green-400" }, { icon: BookOpen, title: "GraphQL API", description: "Flexible data querying with GraphQL", href: "/docs/api/graphql", status: "Coming Soon", statusColor: "text-yellow-400" } ]; const quickExamples = [ { title: "Create Repository", method: "POST", endpoint: "/api/repos", code: `curl -X POST https://git.yourcompany.com/api/repos \\ -H "Authorization: Bearer YOUR_TOKEN" \\ -H "Content-Type: application/json" \\ -d '{ "name": "my-project", "description": "My awesome project", "visibility": "private" }'` }, { title: "List Pull Requests", method: "GET", endpoint: "/api/repos/:owner/:repo/pulls", code: `curl https://git.yourcompany.com/api/repos/owner/repo/pulls \\ -H "Authorization: Bearer YOUR_TOKEN"` }, { title: "Create Pull Request", method: "POST", endpoint: "/api/repos/:owner/:repo/pulls", code: `curl -X POST https://git.yourcompany.com/api/repos/owner/repo/pulls \\ -H "Authorization: Bearer YOUR_TOKEN" \\ -H "Content-Type: application/json" \\ -d '{ "title": "Add new feature", "head": "feature-branch", "base": "main", "body": "This PR adds..." }'` } ]; ---

API Documentation

Integrate OpenCodeHub into your workflow with our comprehensive REST API

{apiSections.map((section) => { const Icon = section.icon; return (
{section.status}

{section.title}

{section.description}

); })}

Quick Start

1. Get API Token

Generate a personal access token from your settings:

  1. Go to Settings → Tokens
  2. Click "Generate New Token"
  3. Select scopes: repo, pr
  4. Copy and save your token securely

2. API Base URL

All API requests should be made to:

https://git.yourcompany.com/api

Replace git.yourcompany.com with your instance URL

Quick Examples

{quickExamples.map((example) => (

{example.title}

{example.method} {example.endpoint}
{example.code}
))}

Rate Limiting

Authenticated Requests

5,000

requests per hour

Unauthenticated Requests

60

requests per hour

Check Limits

Response headers:

X-RateLimit-Remaining

Response Format

Success Response

{`{
  "data": {
    "id": "repo-123",
    "name": "my-project",
    "owner": {
      "username": "swadhin",
      "id": "user-456"
    },
    "visibility": "private",
    "created_at": "2024-01-01T12:00:00Z"
  },
  "meta": {
    "timestamp": "2024-01-01T12:00:01Z"
  }
}`}

Error Response

{`{
  "error": {
    "code": "VALIDATION_ERROR",
    "message": "Repository name is required",
    "details": {
      "field": "name",
      "constraint": "required"
    }
  },
  "meta": {
    "timestamp": "2024-01-01T12:00:01Z",
    "request_id": "req-abc123"
  }
}`}

SDKs & Libraries

JavaScript/TypeScript

npm install @opencodehub/sdk
View docs →

Python

pip install opencodehub
View docs →

Go

go get github.com/opencodehub/sdk-go
View docs →

Additional Resources