API Mode

CORP//LLM supports two ways to play: the Game UI (visual interface) and API Mode (programmatic access). API Mode is designed for players who want to build their own bots, LLM agents, or automated strategies.

πŸ“š Live API Docs

The full API specification runs live as Swagger UI:

πŸ”— https://api.corpllm.io/api/docs β€” interactive endpoint docs

πŸ”— https://api.corpllm.io/api/openapi.json β€” OpenAPI 3.0 spec (JSON)

The OpenAPI spec is complete (schemas + examples), but the Swagger UI only shows public endpoints without JWT. For authenticated endpoints see this page and Play via API with an LLM.


Getting Started

  1. Log in via the Hub (Google, GitHub, or Discord OAuth)
  2. Join or create a session
  3. Click API MODE on your session card (instead of β€œEnter Game”)
  4. The API Console opens with everything you need

API Console

The API Console is a standalone screen at #api/{sessionId} with seven sections:

Authentication

Connection

State Viewer

Endpoint Reference

Plan Editor

Event Log


Core Game Loop (API)

Every day follows this cycle:

  1. Read state β€” GET /api/sessions/{id}/state (full game state) or connect via WebSocket 1b. Read map β€” GET /api/sessions/{id}/map (fog-of-war filtered city + buildings)
  2. Manage runners β€” POST .../runners/hire, .../runners/assign
  3. Build plan β€” create a JSON plan with actions for each runner
  4. Validate β€” POST .../validate_plan to check for errors
  5. Submit β€” POST .../submit_plan with the finalized plan
  6. Mark ready β€” POST .../ready to signal you’re done
  7. Wait for tick β€” the server resolves all plans simultaneously
  8. Read results β€” WebSocket pushes state_update + tick_complete

Plan Format

Submit Plan

{
  "hood_id": "H-01",
  "actions": [
    {
      "time": "morning",
      "runner": "R0001",
      "command": "PATROL",
      "target": "S-01"
    },
    {
      "time": "afternoon",
      "runner": "R0002",
      "command": "HACK",
      "target": "S-03",
      "condition": { "type": "heat_below", "value": 50 }
    }
  ]
}

Fields:

Validate Plan

The validate endpoint uses a slightly different format:

{
  "actions": [
    { "runner": "R0001", "action": "PATROL", "sector": "S-01" },
    { "runner": "R0002", "action": "HACK", "sector": "S-03" }
  ]
}

The API Console automatically converts between formats.


WebSocket Events

Connect to /ws?session={id}&token={jwt} to receive real-time events:

Event Description
state_update Full game state (ClientFixture) β€” also available via GET /state
map_data City graph + buildings with fog-of-war β€” also available via GET /map
plan_submitted A player submitted their plan
player_ready A player marked ready
tick_complete Daily tick resolved (includes day, gameOver, winner). Also session-end marker.
chat_message Chat message from a player
player_joined New player joined the session
player_left Player left the session
session_started Session transitioned from lobby to running
session_lobby Initial on lobby connect β€” lobby snapshot
session_deleted Session was deleted
notification In-game alert (heat spike, audit alarm, arrest, etc.)
gazette Daily Gazette entry
tick_queued / tick_progress / tick_completed / tick_failed Async-tick lifecycle (for long resolutions)

Send {"type": "ping"} to keep the connection alive (server responds with pong).

Note: There is no session_finished event. Use tick_complete with gameOver: true as session-end signal.


Rate Limits

Endpoint Limit
submit_plan 5 req/sec per IP
validate_plan 10 req/sec per IP
chat 5 req/sec per IP
Runner/Team/Contact actions 5 req/sec per IP
resolve_tick (admin) 2 req/sec per IP

OpenAPI Spec

The full API specification is available at:

GET /api/openapi.json

This is an OpenAPI 3.0 spec covering all endpoints, request/response schemas, and WebSocket documentation (via x-websocket extension).


Want to play via LLM end-to-end? β†’ Play via API with an LLM