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

# API

Imperial's REST and WebSocket API serves market data, account data and trading.

* **Base URL:** `https://api.imperial.trade/api/v1`
* **Interactive reference:** [api.imperial.trade/api/v1/docs](https://api.imperial.trade/api/v1/docs)
* **OpenAPI spec:** [api.imperial.trade/api/v1/openapi.json](https://api.imperial.trade/api/v1/openapi.json)

### Market data (public)

| Endpoint                                 | Returns                                                                                       |
| ---------------------------------------- | --------------------------------------------------------------------------------------------- |
| `GET /armada/markets`                    | Every listed market with max leverage (isolated and cross), maintenance and liquidation terms |
| `GET /armada/orderbook`                  | Order book depth for a market                                                                 |
| `GET /armada/quote`                      | Expected fill price for a size                                                                |
| `GET /armada/status`                     | Market and platform status                                                                    |
| `GET /armada/open-availability`          | Whether a new open would be accepted right now, with the reason if not                        |
| `GET /armada/fills`                      | Recent fills                                                                                  |
| `GET /funding-rates`, `GET /mark-prices` | Funding and mark prices                                                                       |

### Account data

`/positions`, `/orders`, `/order-history`, `/trades`, `/funding-history`, `/pnl-history`, and `/armada/margin` for margin account balances.

### Trading

1. Authenticate with your wallet: `POST /mobile/connect`, sign the challenge, then `POST /mobile/exchange` for a token.
2. Place orders with `POST /mobile/orders` (`underwriter: 7`). Opening orders need a non-zero `slippageBps`.
3. Preview fees with `GET /trade-preview`.

### WebSockets

`/ws` streams account updates and `/ws/market` streams market data.

### Example

```bash
curl https://api.imperial.trade/api/v1/armada/markets
```

See [Risk Limits](https://docs.imperial.space/trading/risk-limits#api-rate-limits) for rate limits.
