REST API
AiSpinner provides a REST API at https://api.aispinner.io.
All endpoints require authentication via Bearer token (JWT), obtained through the login endpoint.
Authentication
Login
POST /login
Content-Type: application/json
{
"email": "user@example.com",
"password": "your_password"
}Response:
{
"access_token": "eyJhbGciOiJIUzI1NiIs...",
"token_type": "bearer"
}Get Current User
GET /me
Authorization: Bearer <token>Response:
{
"id": 1,
"email": "user@example.com",
"nickname": "username",
"plan": "free"
}Register
POST /register/start
Content-Type: application/json
{"email": "user@example.com", "password": "...", "nickname": "username"}Sends a confirmation code to the email. Confirm with:
POST /register/confirm
Content-Type: application/json
{"email": "user@example.com", "code": "123456"}Workspaces
List Workspaces
GET /workspaces
Authorization: Bearer <token>Get Workspace with Graph
GET /workspaces/me
Authorization: Bearer <token>Returns the current workspace including the full graph (blocks and edges).
Get Graph
GET /workspaces/{id}/graph
Authorization: Bearer <token>Response:
{
"version": 42,
"graph_json": {
"nodes": [
{
"id": "node_abc123",
"type": "code.worker",
"data": {
"label": "My Worker",
"x": 100,
"y": 200,
"cfg": {"tick_interval": 10}
}
}
],
"edges": [
{
"id": "edge_1",
"source": "node_abc123",
"target": "node_def456"
}
]
}
}Save Graph
PUT /workspaces/{id}/graph
Authorization: Bearer <token>
Content-Type: application/json
{
"version": 42,
"graph_json": { ... }
}Uses optimistic locking -- the version must match the server's current version.
Workers
Deploy Worker Code
POST /workers/deploy
Authorization: Bearer <token>
Content-Type: application/json
{
"workspace_id": 1,
"node_id": "worker_abc123",
"code": "def setup(ctx): pass\ndef tick(ctx): pass",
"tick_interval": 10,
"max_errors": 5,
"auto_heal": true,
"connected_blocks": {
"trading_node_id": "bybit_1",
"monitor_node_ids": ["monitor_1"]
}
}Start Worker
POST /workers/{workspace_id}/{node_id}/start
Authorization: Bearer <token>Stop Worker
POST /workers/{workspace_id}/{node_id}/stop
Authorization: Bearer <token>Get Worker Status
GET /workers/{workspace_id}/{node_id}/status
Authorization: Bearer <token>Response:
{
"status": "running",
"tick_count": 1234,
"error_count": 0,
"tick_interval": 10,
"auto_heal": true,
"max_errors": 5,
"last_tick_at": "2026-03-10T12:34:56Z"
}Get Worker Logs
GET /workers/{workspace_id}/{node_id}/logs?limit=100&level=info
Authorization: Bearer <token>Update Worker Settings
PATCH /workers/{workspace_id}/{node_id}/settings
Authorization: Bearer <token>
Content-Type: application/json
{
"tick_interval": 30,
"max_errors": 10,
"auto_heal": false
}No redeployment needed -- settings update immediately.
Node Configs
Get Node Config
GET /workspaces/{workspace_id}/nodes/{node_id}/config
Authorization: Bearer <token>Update Node Config
PUT /workspaces/{workspace_id}/nodes/{node_id}/config
Authorization: Bearer <token>
Content-Type: application/json
{
"config_json": {
"api_key_id": 1,
"tick_interval": 10
}
}MCP (Model Context Protocol)
AiSpinner exposes an MCP endpoint for AI assistant integration:
Endpoint: https://api.aispinner.io/mcp-api/mcp
Auth: Bearer token (same JWT as REST API)Available MCP tools: get_workspace_graph, get_node_config, list_block_types, get_worker_logs, get_call_history, add_node, remove_node, connect_nodes, disconnect_nodes, update_node_config, rename_node, restart_worker, start_dialer.
Error Responses
All errors follow this format:
{
"detail": "Error description here"
}Common HTTP status codes:
401-- Not authenticated (missing or invalid token)403-- Forbidden (insufficient plan or permissions)404-- Resource not found409-- Version conflict (optimistic locking on graph save)422-- Validation error500-- Server error