> 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/exchanges.md).

# Exchanges

Manage connected exchange accounts.

## Endpoints

| Method | Path                     | Description               |
| ------ | ------------------------ | ------------------------- |
| GET    | `/v1/exchanges`          | List exchange accounts    |
| GET    | `/v1/exchanges/:id`      | Get exchange account      |
| POST   | `/v1/exchanges`          | Add exchange account      |
| DELETE | `/v1/exchanges/:id`      | Remove exchange account   |
| POST   | `/v1/exchanges/test`     | Test exchange credentials |
| POST   | `/v1/exchanges/:id/sync` | Sync exchange balance     |

***

### List Exchange Accounts

```
GET /v1/exchanges
```

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

**Response:**

```json
{
  "success": true,
  "data": [
    {
      "id": "exc_abc123",
      "exchange_name": "binance",
      "account_name": "Main Binance",
      "trading_type": "spot",
      "is_active": true,
      "balance": { "BTC": 1.5, "USDT": 10000 },
      "last_sync_at": "2026-02-20T12:00:00Z",
      "created_at": "2026-01-15T10:30:00Z"
    }
  ]
}
```

***

### Get Exchange Account

```
GET /v1/exchanges/:id
```

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

***

### Add Exchange Account

```
POST /v1/exchanges
```

**Request Body:**

```json
{
  "exchange_name": "binance",
  "account_name": "My Binance",
  "trading_type": "spot",
  "api_key": "your_exchange_api_key",
  "api_secret": "your_exchange_api_secret",
  "passphrase": "optional_passphrase"
}
```

```bash
curl -X POST https://api.tokenbot.com/v1/exchanges \
  -H "X-API-Key: tb_live_your_key" \
  -H "Content-Type: application/json" \
  -d '{"exchange_name":"binance","account_name":"My Binance","trading_type":"spot","api_key":"...","api_secret":"..."}'
```

***

### Remove Exchange Account

```
DELETE /v1/exchanges/:id
```

```bash
curl -X DELETE https://api.tokenbot.com/v1/exchanges/exc_abc123 \
  -H "X-API-Key: tb_live_your_key"
```

***

### Test Exchange Credentials

```
POST /v1/exchanges/test
```

Test exchange API credentials before saving.

**Request Body:**

```json
{
  "exchange_name": "binance",
  "api_key": "your_exchange_api_key",
  "api_secret": "your_exchange_api_secret",
  "trading_type": "spot"
}
```

***

### Sync Exchange Balance

```
POST /v1/exchanges/:id/sync
```

Force a balance sync with the exchange.

```bash
curl -X POST https://api.tokenbot.com/v1/exchanges/exc_abc123/sync \
  -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/exchanges.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.
