Quick Start

Get started with Code Hub API in just a few minutes. Follow these simple steps to make your first API call.

🔥 5-Minute Integration

  1. Sign up: Create your free Code Hub account
  2. Generate API key: Go to Settings → API Dashboard
  3. Make your first call: Test with the execute endpoint
  4. Build amazing apps: Integrate into your applications

Test Your Integration

// Test API call - Execute Python code
const response = await fetch('https://codehubpro.org/api/v1/execute', {
    method: 'POST',
    headers: {
        'Authorization': 'Bearer ch_live_sk_your_api_key_here',
        'Content-Type': 'application/json'
    },
    body: JSON.stringify({
        language: 'python',
        code: 'print("Hello from Code Hub API!")',
        input: ''
    })
});

const result = await response.json();
console.log(result.output); // "Hello from Code Hub API!"
                    

Rate Limits

Code Hub API implements rate limiting to ensure fair usage and maintain service quality for all users.

Rate Limit Tiers

Plan Requests/Hour Requests/Minute Burst Limit
Free 100 10 20
Pro 5,000 100 200
Business 25,000 500 1,000
Enterprise 100,000 1,000 2,000

Rate Limit Headers

X-RateLimit-Limit: 100
X-RateLimit-Remaining: 95
X-RateLimit-Reset: 1640995200
X-RateLimit-Window: 3600
                    

Handling Rate Limits

const makeAPICall = async () => {
    try {
        const response = await fetch(apiEndpoint, {
            headers: { 'Authorization': 'Bearer your_token' }
        });
        
        if (response.status === 429) {
            const resetTime = response.headers.get('X-RateLimit-Reset');
            const waitTime = (resetTime * 1000) - Date.now();
            
            console.log(`Rate limited. Waiting ${waitTime}ms`);
            await new Promise(resolve => setTimeout(resolve, waitTime));
            
            return makeAPICall(); // Retry
        }
        
        return response.json();
    } catch (error) {
        console.error('API call failed:', error);
    }
};
                    

Authentication

Code Hub API uses Bearer token authentication. You can generate API tokens from your account settings.

🔑 Getting Your API Token

  1. Log in to your Code Hub account
  2. Go to Settings → API Tokens
  3. Click "Generate New Token"
  4. Copy and securely store your token
// Include the Authorization header in all API requests
const response = await fetch('https://codehubpro.org/api/v1/projects', {
    headers: {
        'Authorization': 'Bearer YOUR_API_TOKEN',
        'Content-Type': 'application/json'
    }
});
                    

🌍 Base URL

All API requests should be made to:

https://codehubpro.org/api/v1/

Rate Limits

  • Free Plan: 1,000 requests per hour
  • Pro Plan: 10,000 requests per hour
  • Enterprise Plan: 100,000 requests per hour

Projects API

GET https://codehubpro.org/api/v1/projects

Retrieve all projects for the authenticated user.

Headers

Name Type Required Description
Authorization string Required Bearer token for authentication

JavaScript Example

const response = await fetch('https://codehubpro.org/api/v1/projects', {
    method: 'GET',
    headers: {
        'Authorization': 'Bearer ch_live_sk_your_api_key_here',
        'Content-Type': 'application/json'
    }
});

const data = await response.json();
console.log('Projects:', data.projects);
                        

cURL Example

curl -X GET "https://codehubpro.org/api/v1/projects" \
  -H "Authorization: Bearer ch_live_sk_your_api_key_here" \
  -H "Content-Type: application/json"
                        

Response

{
  "success": true,
  "projects": [
    {
      "id": "proj_abc123def456",
      "name": "My Website",
      "description": "Personal portfolio website",
      "language": "html",
      "created_at": "2025-01-15 10:30:00",
      "updated_at": "2025-01-16 14:20:00",
      "is_public": false
    }
  ],
  "count": 1
}
                        
POST https://codehubpro.org/api/v1/projects

Create a new project.

Parameters

Name Type Required Description
name string Required Project name (max 100 characters)
description string Optional Project description
language string Optional Programming language (default: javascript)
code string Optional Initial code content
is_public boolean Optional Make project public (default: false)

JavaScript Example

const projectData = {
    name: "My New Project",
    description: "A sample project created via API",
    language: "javascript",
    code: "console.log('Hello, World!');",
    is_public: false
};

const response = await fetch('https://codehubpro.org/api/v1/projects', {
    method: 'POST',
    headers: {
        'Authorization': 'Bearer ch_live_sk_your_api_key_here',
        'Content-Type': 'application/json'
    },
    body: JSON.stringify(projectData)
});

const result = await response.json();
console.log('Created project:', result.project);
                        
GET https://codehubpro.org/api/v1/projects/{project_id}

Retrieve details of a specific project.

Path Parameters

Name Type Required Description
project_id string Required Unique project identifier

JavaScript Example

const response = await fetch('https://codehubpro.org/api/v1/projects/proj_abc123def456', {
    method: 'GET',
    headers: {
        'Authorization': 'Bearer ch_live_sk_your_api_key_here',
        'Content-Type': 'application/json'
    }
});

const project = await response.json();
console.log('Project details:', project);
                        

Update Project

PUT https://codehubpro.org/api/v1/projects/{project_id}

Update an existing project's details.

Parameters

Name Type Required Description
name string Optional Updated project name
description string Optional Updated project description
is_public boolean Optional Update project visibility

JavaScript Example

const updates = {
    name: "Updated Project Name",
    description: "New project description",
    is_public: true
};

const response = await fetch('https://codehubpro.org/api/v1/projects/proj_abc123def456', {
    method: 'PUT',
    headers: {
        'Authorization': 'Bearer ch_live_sk_your_api_key_here',
        'Content-Type': 'application/json'
    },
    body: JSON.stringify(updates)
});

const updatedProject = await response.json();
                        

Delete Project

DELETE https://codehubpro.org/api/v1/projects/{project_id}

Permanently delete a project and all its associated files.

⚠️ Warning

This action cannot be undone. All project files, deployments, and history will be permanently removed.

JavaScript Example

const response = await fetch('https://codehubpro.org/api/v1/projects/proj_abc123def456', {
    method: 'DELETE',
    headers: {
        'Authorization': 'Bearer ch_live_sk_your_api_key_here'
    }
});

if (response.ok) {
    console.log('Project deleted successfully');
} else {
    console.error('Failed to delete project');
}
                        

Code Execution API

POST https://codehubpro.org/api/v1/execute

Execute code in the cloud and get the output. Supports JavaScript, Python, PHP, and HTML.

Parameters

Name Type Required Description
language string Required Programming language: javascript, python, php, html
code string Required Code to execute
input string Optional Input data for the program

JavaScript Example

const executeData = {
    language: "python",
    code: "print('Hello from Code Hub API!')\nresult = 2 + 3\nprint(f'2 + 3 = {result}')"
};

const response = await fetch('https://codehubpro.org/api/v1/execute', {
    method: 'POST',
    headers: {
        'Authorization': 'Bearer ch_live_sk_your_api_key_here',
        'Content-Type': 'application/json'
    },
    body: JSON.stringify(executeData)
});

const result = await response.json();
console.log('Output:', result.output);
console.log('Execution time:', result.execution_time + 'ms');
                        

Response

{
  "success": true,
  "output": "Hello from Code Hub API!\n2 + 3 = 5",
  "execution_time": 125.45,
  "language": "python"
}
                        

Authentication API

POST https://codehubpro.org/api/v1/auth

Verify API key and get user permissions.

Parameters

Name Type Required Description
action string Required Action type: "authenticate" or "generate_key"
api_key string Required Your API key (for authenticate action)

JavaScript Example

const authData = {
    action: "authenticate",
    api_key: "ch_live_sk_your_api_key_here"
};

const response = await fetch('https://codehubpro.org/api/v1/auth', {
    method: 'POST',
    headers: {
        'Content-Type': 'application/json'
    },
    body: JSON.stringify(authData)
});

const result = await response.json();
console.log('User plan:', result.plan);
console.log('Rate limit:', result.rate_limit);
                        

💰 API Pricing & Business Integration

Perfect for businesses that want to integrate cloud development features into their platforms.

🚀 Starter Plan

$29/month

  • 10,000 API calls/month
  • Basic code execution
  • Email support
  • Rate limit: 100/hour

💼 Business Plan

$99/month

  • 100,000 API calls/month
  • Advanced features
  • Priority support
  • Rate limit: 1,000/hour

🏢 Enterprise Plan

Custom Pricing

  • Unlimited API calls
  • Custom integrations
  • 24/7 phone support
  • Custom rate limits

🎯 Perfect For:

  • EdTech Platforms: Add coding challenges and assessments
  • No-Code Tools: Integrate code execution into visual builders
  • Learning Management Systems: Automatic code grading
  • Developer Tools: Cloud-based code compilation
  • SaaS Applications: Custom automation and scripting
Contact Sales Team

🚀 Try the API Now

Live API Testing

Test our API endpoints with demo credentials:

// Demo API Key (limited to 10 requests per hour)
const DEMO_API_KEY = "ch_test_sk_demo987654321";

// Test code execution
const testExecution = async () => {
    const response = await fetch('https://codehubpro.org/api/v1/execute', {
        method: 'POST',
        headers: {
            'Authorization': `Bearer ${DEMO_API_KEY}`,
            'Content-Type': 'application/json'
        },
        body: JSON.stringify({
            language: 'javascript',
            code: 'console.log("API test successful!");'
        })
    });
    
    const result = await response.json();
    console.log(result);
};

testExecution();
                        
✅ Ready to integrate? Get your production API key from your dashboard and start building amazing features!

Error Handling

All API endpoints return consistent error responses in JSON format.

Standard Error Response

{
  "error": "Error description",
  "code": "ERROR_CODE",
  "details": "Additional error information (optional)"
}
                    

Common Error Codes

HTTP Status Error Code Description
400 MISSING_PARAMETERS Required parameters are missing
401 UNAUTHORIZED Invalid or missing API key
403 FORBIDDEN Insufficient permissions
404 NOT_FOUND Resource not found
429 RATE_LIMIT_EXCEEDED Too many requests
500 INTERNAL_ERROR Server error

SDK Examples

Node.js SDK

// Install: npm install @codehub/api-client
const CodeHub = require('@codehub/api-client');

const client = new CodeHub({
    apiKey: 'ch_live_sk_your_api_key_here',
    baseURL: 'https://codehubpro.org/api/v1'
});

// Execute code
const result = await client.execute({
    language: 'python',
    code: 'print("Hello from SDK!")'
});

console.log('Output:', result.output);
                        

Python SDK

# Install: pip install codehub-api
from codehub import CodeHubClient

client = CodeHubClient(
    api_key='ch_live_sk_your_api_key_here',
    base_url='https://codehubpro.org/api/v1'
)

# Create project
project = client.projects.create({
    'name': 'My Python Project',
    'language': 'python',
    'code': 'print("Hello, World!")'
})

print(f"Created project: {project['name']}")