Spectra

API Reference

SDK and REST API documentation

API Reference

Authentication

Authorization: Bearer YOUR_API_KEY

Store your API key in environment variables. Never commit to version control.

SDK

Config

interface Config {
  maxPositionSize: number;
  maxDailyLoss: number;
  riskTolerance: 'conservative' | 'moderate' | 'aggressive';
  maxFrequencyPerMin: number;
  allowedStrategies: string[];
  preferredTokens?: string[];
}

Agent Methods

# Deploy
agent.deploy(environment='sandbox')  # or 'production'
agent.deploy(environment='production', circuit_breaker=True)

# Backtest
results = agent.run_backtest(start_date, end_date, initial_capital)

# Event handlers
agent.on_rogue_detected(callback)
agent.on_anomaly_detected(callback)
agent.on_circuit_breaker_triggered(callback)

REST API

Log Trade

POST /api/v1/trade

{
  "agentId": "alpha",
  "action": "buy",
  "token": "SOL",
  "amount": 1000,
  "strategy": "momentum"
}

Response:

{
  "tradeId": "trade_12345",
  "behavior": "conservative",
  "riskScore": 15
}

Get Agent Status

GET /api/v1/agent/:agentId

{
  "agentId": "alpha",
  "status": "running",
  "behavior": "conservative",
  "totalTrades": 145,
  "dailyPnL": 2500,
  "riskScore": 25
}

Get Analytics

GET /api/v1/analytics?agentId=alpha&startDate=2026-01-01

{
  "totalTrades": 500,
  "winRate": 0.62,
  "sharpeRatio": 1.8,
  "maxDrawdown": 0.15,
  "behaviorBreakdown": {
    "conservative": 0.7,
    "aggressive": 0.2,
    "anomalous": 0.1
  }
}

Webhooks

Event Types

agent.rogue_detected

{
  "event": "agent.rogue_detected",
  "data": { "agentId": "alpha", "riskScore": 87, "reason": "High frequency trading" }
}

agent.anomaly_detected

{
  "event": "agent.anomaly_detected",
  "data": { "agentId": "alpha", "anomalies": ["unusual_position_size"], "severity": "high" }
}

circuit_breaker.triggered

{
  "event": "circuit_breaker.triggered",
  "data": { "agentId": "alpha", "reason": "Max daily loss exceeded", "lossAmount": 5234.5 }
}

Rate Limits

TierLimit
Free100/min
Pro1,000/min
EnterpriseCustom

Error Codes

CodeDescription
401Invalid API key
400Invalid parameters
404Agent not found
429Rate limited

On this page