> For the complete documentation index, see [llms.txt](https://docs.nexus.xyz/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.nexus.xyz/exchange/apis-and-rates.md).

# APIs & Rates

The Nexus Exchange is API-first. Everything a trader can do — fund an account, place and cancel orders, query positions, stream the order book — is available over REST and WebSocket. The web frontend is a read-only view; programmatic access is the primary interface.

### Base URL

```
https://exchange.nexus.xyz/api/exchange
```

This is the testnet preview gateway. The machine-readable OpenAPI specification is served at `/openapi.json` and versioned at [`nexus-xyz/nexus-exchange-api`](https://github.com/nexus-xyz/nexus-exchange-api); releases are tracked on [GitHub Releases](https://github.com/nexus-xyz/nexus-exchange-api/releases).

### Authentication model

There are two credential types:

1. **Session token (Bearer).** Created by signing a fixed message with your Ethereum wallet (EIP-191). Used **only** to create and manage API keys — never for trading. Expires after 24 hours.
2. **API key (HMAC).** A `key_id` + `secret` pair. Every trading and account request is signed with HMAC-SHA256 over a canonical request string. The secret is shown once at creation and cannot be retrieved later.

```
1. POST /auth/login   (wallet signature)        → session Bearer token
2. POST /keys         (Bearer)                   → API key_id + secret
3. sign each request  (HMAC over canonical str)  → trade
```

See the Quickstart for the full flow with runnable cURL.

### CCXT

CCXT-compatible **read** endpoints are available today (markets, tickers, order book, trades, balances, positions), tagged in the OpenAPI spec. Broader CCXT support, including order placement, is planned.

### Reference

* Quickstart: Your First Trade
* REST API Reference
* WebSocket API Reference
* Rate & Connection Limits
* [API Versioning](/exchange/apis-and-rates/api-versioning.md)

> **Status:** testnet preview. Credentials, sessions, and rate-limit state are not yet durable across gateway restarts — treat API keys as re-creatable. Production hardening is in progress.


---

# 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.nexus.xyz/exchange/apis-and-rates.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.
