> 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
