Skip to main content

Run CodeGate with Docker

If CodeGate is not deployed yet, pull the image:
docker pull pfeak/codegate:latest
Start the container:
docker run -d --name codegate \
  -p 8877:8877 \
  -v codegate-data:/app/backend/data \
  --restart unless-stopped \
  pfeak/codegate:latest
Parameter notes:
-p 8877:8877: Maps the admin UI port
-v codegate-data:/app/backend/data: Mounts a volume for data persistence
Then open:
  • Admin UI: <http://localhost:8877>
Use base_url = http://localhost:8877 in the steps below (or your host/domain if the API and caller are on different machines).

Prerequisites

  • A running CodeGate instance (API URL and admin UI). If you used the Docker command above, nothing else is needed.

Step 1: Install the SDK

Choose by stack:
pip install codegate-sdk
Or with uv:
uv pip install codegate-sdk

Step 2: Create a project and API key in CodeGate

  1. Log in to the CodeGate admin UI.
  2. Create a project (if needed).
  3. Go to project details → API keys.
  4. Click Generate key to get api_key, secret, and project_id.
Secret is shown only once. Save it immediately; it cannot be viewed again.

Step 3: Initialize the client

from codegate_sdk import CodeGateClient

client = CodeGateClient(
    api_key="550e8400e29b41d4a716446655440000",
    secret="a1b2c3d4e5f6...",
    project_id="550e8400e29b41d4a716446655440000",
    base_url="https://api.example.com"
)
Replace api_key, secret, project_id with your credentials and base_url with your CodeGate API URL.

Step 4: Verify an activation code

Before verification: Make sure you have created at least 1 valid activation code in your project before verifying. You can create activation codes in the admin UI under project details → Activation codes.
result = client.verify_code(code="ABC12345", verified_by="user123")
if result['success']:
    print(f"Verified at: {result['verified_at']}")
else:
    print(f"Failed: {result['error_code']} - {result['message']}")
For production, use environment variables for credentials:
Environment variableDescription
CODEGATE_API_KEYAPI Key
CODEGATE_SECRETAPI Secret
CODEGATE_PROJECT_IDProject ID
CODEGATE_BASE_URLAPI base URL (optional, default https://api.example.com)
import os
client = CodeGateClient(
    api_key=os.getenv("CODEGATE_API_KEY"),
    secret=os.getenv("CODEGATE_SECRET"),
    project_id=os.getenv("CODEGATE_PROJECT_ID"),
    base_url=os.getenv("CODEGATE_BASE_URL", "https://api.example.com")
)

Next steps