> ## Documentation Index
> Fetch the complete documentation index at: https://cryptorobot.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# API Reference

> Complete reference for all Cryptorobot.ai API endpoints

## Quick Start with the Client SDK

The recommended way to interact with the Cryptorobot.ai API is via the official **`@cryptorobot.ai/client`** npm package over WebSockets. This gives you real-time events, typed services, and automatic reconnection.

```bash theme={null}
npm install @cryptorobot.ai/client
```

```typescript theme={null}
import { createClient } from '@cryptorobot.ai/client';

// Connect via WebSocket (recommended)
const client = createClient('https://api.cryptorobot.ai');

// Authenticate
await client.authenticate({
  strategy: 'local',
  email: 'you@example.com',
  password: 'your-password'
});

// Use typed services
const strategies = await client.service('strategies').find({
  query: { $limit: 10, $sort: { createdAt: -1 } }
});

// Listen for real-time events
client.service('traders/pods/events').on('created', (event) => {
  console.log('New pod event:', event);
});
```

<Note>
  The client SDK supports both WebSocket (recommended) and REST transports. WebSocket provides real-time event streaming and lower latency.
</Note>

## REST API

For direct HTTP access, use the base URL:

```
https://api.cryptorobot.ai
```

### Authentication

All authenticated endpoints require one of:

<CodeGroup>
  ```bash JWT Token theme={null}
  Authorization: Bearer eyJhbGciOiJIUzI1NiIs...
  ```

  ```bash API Key theme={null}
  Authorization: ApiKey cr_live_a1b2c3d4e5f6...
  ```
</CodeGroup>

### HTTP Methods

| Method                | Service Method | Description                 |
| --------------------- | -------------- | --------------------------- |
| `GET /service`        | `find`         | List resources (paginated)  |
| `GET /service/:id`    | `get`          | Get a single resource       |
| `POST /service`       | `create`       | Create a new resource       |
| `PATCH /service/:id`  | `patch`        | Partially update a resource |
| `DELETE /service/:id` | `remove`       | Delete a resource           |

### Common Query Parameters

| Parameter          | Type    | Description                                                         |
| ------------------ | ------- | ------------------------------------------------------------------- |
| `$limit`           | integer | Items per page (default: 25, max: 100)                              |
| `$skip`            | integer | Items to skip for pagination                                        |
| `$sort[field]`     | 1 \| -1 | Sort direction (1 = ascending, -1 = descending)                     |
| `$select[]`        | string  | Fields to include in response                                       |
| `field[$operator]` | varies  | Filter operator: `$gt`, `$gte`, `$lt`, `$lte`, `$ne`, `$in`, `$nin` |

## Response Format

### Paginated List (Find)

```json theme={null}
{
  "total": 142,
  "limit": 25,
  "skip": 0,
  "data": [{ ... }, { ... }]
}
```

### Single Resource (Get / Create / Patch)

```json theme={null}
{
  "_id": "507f1f77bcf86cd799439011",
  "field": "value",
  "createdAt": "2024-01-15T10:30:00.000Z",
  "updatedAt": "2024-01-15T10:30:00.000Z"
}
```

### Error

```json theme={null}
{
  "name": "NotAuthenticated",
  "message": "Invalid access token",
  "code": 401,
  "className": "not-authenticated"
}
```

## Rate Limits

| Header                  | Description                          |
| ----------------------- | ------------------------------------ |
| `X-RateLimit-Limit`     | Max requests per minute              |
| `X-RateLimit-Remaining` | Remaining in current window          |
| `X-RateLimit-Reset`     | Unix timestamp when window resets    |
| `Retry-After`           | Seconds to wait (429 responses only) |

## Endpoint Groups

<CardGroup cols={3}>
  <Card title="Authentication" icon="lock" href="/api-reference/authentication/login">
    Login, logout, token management
  </Card>

  <Card title="Users" icon="user" href="/api-reference/users/get-current-user">
    Profile, sessions, onboarding
  </Card>

  <Card title="Exchanges" icon="building-columns" href="/api-reference/exchanges/list-exchanges">
    Connections, balances, market data
  </Card>

  <Card title="Strategies" icon="brain" href="/api-reference/strategies/list-strategies">
    CRUD, backtesting, AI generation
  </Card>

  <Card title="Traders & Bots" icon="robot" href="/api-reference/traders/list-traders">
    Bot management, pods, events
  </Card>

  <Card title="Models & Signals" icon="signal" href="/api-reference/models/list-signals">
    ML signals, subscriptions
  </Card>

  <Card title="Insights" icon="chart-mixed" href="/api-reference/insights/list-insights">
    Market data, ETF flows, news
  </Card>

  <Card title="Portfolio" icon="chart-pie" href="/api-reference/portfolio/balance-series">
    Performance, trades, snapshots
  </Card>

  <Card title="Agents" icon="microchip" href="/api-reference/agents/list-agents">
    AI agents and conversations
  </Card>

  <Card title="Payments" icon="credit-card" href="/api-reference/payments/list-subscriptions">
    Subscriptions, payment methods
  </Card>

  <Card title="Events" icon="bell" href="/api-reference/events/list-events">
    Event log, triggers, notifications
  </Card>
</CardGroup>
