> For the complete documentation index, see [llms.txt](https://docs.tokenbot.com/home/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.tokenbot.com/home/api-docs/rest-api/trades.md).

# Trades

View and manage trades.

## Endpoints

| Method | Path                    | Description         |
| ------ | ----------------------- | ------------------- |
| GET    | `/v1/trades`            | List trades         |
| GET    | `/v1/trades/:id`        | Get trade           |
| GET    | `/v1/trades/analytics`  | Get trade analytics |
| POST   | `/v1/trades`            | Create trade        |
| POST   | `/v1/trades/:id/cancel` | Cancel trade        |

***

### List Trades

```
GET /v1/trades
```

**Query Parameters:**

| Parameter             | Type    | Description                                                    |
| --------------------- | ------- | -------------------------------------------------------------- |
| `strategy_id`         | string  | Filter by strategy                                             |
| `exchange_account_id` | string  | Filter by exchange account                                     |
| `status`              | string  | `PENDING`, `FILLED`, `PARTIALLY_FILLED`, `CANCELLED`, `FAILED` |
| `side`                | string  | `BUY` or `SELL`                                                |
| `limit`               | integer | Max results (default 50, max 100)                              |
| `offset`              | integer | Pagination offset                                              |

```bash
curl "https://api.tokenbot.com/v1/trades?status=FILLED&limit=10" \
  -H "X-API-Key: tb_live_your_key"
```

***

### Get Trade

```
GET /v1/trades/:id
```

***

### Get Trade Analytics

```
GET /v1/trades/analytics
```

Returns aggregated trade performance metrics.

```bash
curl https://api.tokenbot.com/v1/trades/analytics \
  -H "X-API-Key: tb_live_your_key"
```

***

### Create Trade

```
POST /v1/trades
```

**Request Body:**

```json
{
  "exchange_account_id": "exc_abc123",
  "trade_pair_id": "tp_btcusdt",
  "type": "LIMIT",
  "side": "BUY",
  "price": 50000.00,
  "amount": 0.1
}
```

***

### Cancel Trade

```
POST /v1/trades/:id/cancel
```

```bash
curl -X POST https://api.tokenbot.com/v1/trades/trd_abc123/cancel \
  -H "X-API-Key: tb_live_your_key"
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.tokenbot.com/home/api-docs/rest-api/trades.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
