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:
Or with uv: uv pip install codegate-sdk
Step 2: Create a project and API key in CodeGate
Log in to the CodeGate admin UI.
Create a project (if needed).
Go to project details → API keys .
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"
)
import { CodeGateClient } from 'codegate-sdk' ;
const client = new CodeGateClient ({
apiKey: '550e8400e29b41d4a716446655440000' ,
secret: 'a1b2c3d4e5f6...' ,
projectId: '550e8400e29b41d4a716446655440000' ,
baseUrl: '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' ] } " )
const result = await client . verifyCode ({ code: 'ABC12345' , verifiedBy: 'user123' });
if ( result . success ) {
console . log ( 'Verified at:' , result . verified_at );
} else {
console . log ( 'Failed:' , result . error_code , result . message );
}
Environment variables (recommended)
For production, use environment variables for credentials:
Environment variable Description 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" )
)
const client = new CodeGateClient ({
apiKey: process . env . CODEGATE_API_KEY ! ,
secret: process . env . CODEGATE_SECRET ! ,
projectId: process . env . CODEGATE_PROJECT_ID ! ,
baseUrl: process . env . CODEGATE_BASE_URL || 'https://api.example.com' ,
});
Next steps
Python SDK More Python usage
JavaScript SDK More JavaScript usage
API reference Call REST API directly