http://localhost:8000/api/v1
The system uses TON Wallet authentication for frontend access. API keys can be used for programmatic access.
GET /api/v1/workersQuery Parameters:
participant_id(optional): Filter by participantis_active(optional): Filter by active status
Response:
[
{
"id": 1,
"participant_id": 1,
"worker_name": "Worker-0",
"instance_number": 0,
"host": "localhost",
"stats_port": 12000,
"is_active": true,
"latest_status": "healthy",
"latest_gpu_utilization": 87.5,
"latest_revenue_ton": 65.3
}
]GET /api/v1/workers/{worker_id}POST /api/v1/workersRequest Body:
{
"participant_id": 1,
"worker_name": "Worker-0",
"instance_number": 0,
"host": "localhost",
"stats_port": 12000,
"price_coefficient": 1.0
}PATCH /api/v1/workers/{worker_id}Request Body:
{
"is_active": false,
"price_coefficient": 1.2
}GET /api/v1/workers/{worker_id}/metrics?hours=24GET /api/v1/workers/{worker_id}/statsGET /api/v1/participantsGET /api/v1/participants/{participant_id}Response:
{
"id": 1,
"ton_wallet_address": "UQAbc...xyz",
"username": "user123",
"is_active": true,
"total_workers": 2,
"active_workers": 2,
"total_revenue_ton": 125.50,
"total_payouts": 5
}POST /api/v1/participantsRequest Body:
{
"ton_wallet_address": "UQAbc...xyz",
"telegram_user_id": 123456789,
"username": "user123",
"email": "user@example.com"
}GET /api/v1/participants/wallet/{wallet_address}GET /api/v1/payouts?participant_id=1&limit=100GET /api/v1/payouts/{payout_id}POST /api/v1/payoutsRequest Body:
{
"participant_id": 1,
"transaction_hash": "abc123...",
"amount_ton": 25.5,
"amount_usd": 89.25,
"from_address": "UQPool...",
"to_address": "UQParticipant...",
"transaction_time": "2025-01-15T10:30:00Z",
"period_start": "2025-01-08T00:00:00Z",
"period_end": "2025-01-15T00:00:00Z"
}GET /api/v1/payouts/participant/{participant_id}/summaryGET /api/v1/payouts/export/tax-report?participant_id=1&year=2025Returns CSV file for tax reporting.
GET /metricsAvailable metrics:
cocoon_worker_status- Worker health statuscocoon_gpu_utilization- GPU utilization percentagecocoon_gpu_memory_used_gb- GPU memory usagecocoon_gpu_temperature_celsius- GPU temperaturecocoon_revenue_ton- Revenue in TONcocoon_inference_requests_total- Total inference requestscocoon_worker_errors_total- Worker errors
All endpoints return standard error responses:
{
"detail": "Error message description"
}HTTP Status Codes:
200- Success201- Created400- Bad Request404- Not Found422- Validation Error500- Internal Server Error
API endpoints are rate-limited to prevent abuse:
- 100 requests per minute per IP for read endpoints
- 20 requests per minute per IP for write endpoints
Real-time updates will be available via WebSocket:
const ws = new WebSocket('ws://localhost:8000/ws/metrics');
ws.onmessage = (event) => {
const metrics = JSON.parse(event.data);
console.log(metrics);
};