Skip to main content
The Lyceum Cloud API enables you to programmatically execute code, manage files, monitor usage, and integrate our cloud compute platform into your applications.

Base URL

All API requests use this base URL:
https://api.lyceum.technology/api/v2/external

Authentication

JWT Tokens

Best for: Web applications, user sessions
  • 24-hour expiration
  • Automatic refresh support
  • Obtained via login endpoint

API Keys

Best for: CI/CD, automation, services
  • No expiration (configurable)
  • Revocable anytime
  • Created in dashboard

Quick Start Authentication

  • Get JWT Token
  • Use Token
  • API Keys
curl -X POST https://api.lyceum.technology/api/v2/external/auth/login \
  -H "Content-Type: application/json" \
  -d '{
    "email": "[email protected]",
    "password": "your-password"
  }'
Response:
{
  "access_token": "eyJhbGci...",
  "refresh_token": "eyJhbGci...",
  "expires_in": 86400
}

API Endpoints

🚀 Code Execution

Execute Python code or Docker containers on cloud infrastructure.
POST /execution/streaming/start
{
  "code": "print('Hello World')",
  "nbcode": 0,
  "execution_type": "cpu",
  "timeout": 300,
  "requirements_content": "pandas==2.0.0"
}
Response:
{
  "execution_id": "uuid",
  "status": "running",
  "streaming_url": "wss://..."
}
POST /execution/image/start
{
  "docker_image_ref": "python:3.11",
  "docker_run_cmd": ["python", "-c", "print('Hello')"],
  "execution_type": "cpu",
  "timeout": 600
}
  • GET /execution/streaming/{id}/status - Check status
  • POST /execution/streaming/abort/{id} - Stop execution
  • POST /execution/streaming/complete/{id} - Mark complete

📁 File Storage

Manage files in cloud storage with S3-compatible API.
POST /storage/upload
curl -X POST .../storage/upload \
  -H "Authorization: Bearer <token>" \
  -F "[email protected]" \
  -F "key=datasets/data.csv"
  • GET /storage/list-files?prefix=datasets/ - List files
  • GET /storage/download/{file_key} - Download file
  • DELETE /storage/delete/{file_key} - Delete file
POST /storage/credentialsGet temporary S3 credentials for direct access:
{
  "access_key_id": "AKIA...",
  "secret_access_key": "...",
  "session_token": "...",
  "expiration": "2024-01-01T12:00:00Z"
}

💳 Billing & Credits

Monitor usage and manage billing.
GET /billing/credits
{
  "available_credits": 100.0,
  "used_credits": 25.0,
  "remaining_credits": 75.0,
  "monthly_free_credits": 20.0,
  "purchased_credits": 80.0
}
GET /billing/history?limit=50&offset=0Returns execution history with costs.
POST /billing/checkout
{
  "credits_amount": 100,
  "success_url": "https://yourapp.com/success",
  "cancel_url": "https://yourapp.com/cancel"
}

🔐 Authentication & Users

Manage authentication and API keys.
  • POST /auth/login - Login with email/password
  • POST /auth/refresh - Refresh access token
  • GET /auth/api-keys/ - List API keys
  • POST /auth/api-keys/ - Create new key
  • DELETE /auth/api-keys/{id} - Delete key
  • PATCH /auth/api-keys/{id}/toggle - Enable/disable
  • DELETE /user/delete - Delete account

🏥 System Health

Monitor API status and version.
  • GET /health/ping - Health check
  • GET /health/version - API version info

Quick Start Examples

  • Python
  • JavaScript
  • cURL
import requests

class LyceumClient:
    def __init__(self, email, password):
        self.base_url = "https://api.lyceum.technology/api/v2/external"
        self.token = self._authenticate(email, password)
    
    def _authenticate(self, email, password):
        response = requests.post(
            f"{self.base_url}/auth/login",
            json={"email": email, "password": password}
        )
        return response.json()["access_token"]
    
    def execute_code(self, code):
        response = requests.post(
            f"{self.base_url}/execution/streaming/start",
            headers={
                "Authorization": f"Bearer {self.token}",
                "Content-Type": "application/json"
            },
            json={
                "code": code,
                "nbcode": 0,
                "execution_type": "cpu"
            }
        )
        return response.json()

# Usage
client = LyceumClient("[email protected]", "password")
result = client.execute_code("print('Hello World')")
print(f"Execution ID: {result['execution_id']}")

Response Format

Success Response

{
  "status": "success",
  "data": {
    // Response data
  },
  "message": "Operation completed successfully"
}

Error Response

{
  "detail": "Error message",
  "status": 400,
  "type": "validation_error",
  "errors": [
    {
      "field": "code",
      "message": "Required field missing"
    }
  ]
}

Rate Limits

Rate limits help ensure fair usage and platform stability. Headers indicate your current usage.
Endpoint CategoryLimitWindow
Authentication10 requestsper minute
Code Execution100 requestsper hour
File Storage1000 requestsper hour
Billing100 requestsper hour
Rate Limit Headers:
  • X-RateLimit-Limit: Maximum requests allowed
  • X-RateLimit-Remaining: Requests remaining
  • X-RateLimit-Reset: Unix timestamp when limit resets

HTTP Status Codes

CodeStatusDescription
200OKRequest successful
201CreatedResource created successfully
400Bad RequestInvalid request parameters
401UnauthorizedAuthentication required or invalid
403ForbiddenAccess denied to resource
404Not FoundResource doesn’t exist
429Too Many RequestsRate limit exceeded
500Internal ErrorServer error occurred
503Service UnavailableService temporarily down

Error Handling

import time
import requests
from requests.exceptions import RequestException

def api_call_with_retry(url, headers, json_data, max_retries=3):
    for attempt in range(max_retries):
        try:
            response = requests.post(url, headers=headers, json=json_data)
            
            if response.status_code == 429:  # Rate limited
                retry_after = int(response.headers.get('Retry-After', 60))
                time.sleep(retry_after)
                continue
            
            response.raise_for_status()
            return response.json()
            
        except RequestException as e:
            if attempt == max_retries - 1:
                raise
            time.sleep(2 ** attempt)  # Exponential backoff
    
    return None

Best Practices

1

Use Environment Variables

Store API credentials securely:
export LYCEUM_API_TOKEN="your-token"
export LYCEUM_API_KEY="lk_live_..."
2

Implement Retry Logic

Handle transient failures gracefully with exponential backoff.
3

Monitor Rate Limits

Check rate limit headers and implement appropriate throttling.
4

Clean Up Resources

Stop unnecessary executions and delete temporary files.
5

Validate Inputs

Check parameters before making API calls to avoid errors.
6

Use Appropriate Timeouts

Set reasonable timeouts for long-running operations.

SDK & Tools

Support