Nexwest's markets run on a shared order book operated by its settlement network. Your API keys are registered on that network under your Nexwest account, so your code talks to its API directly: the lowest latency, and IP allow lists that see your servers' real addresses. New to the API? Start with the Trading API overview, create a key on the API keys page, and follow the trading bot guide for a complete example.
Base URLs
| Service | URL |
|---|---|
| REST | https://api.orderly.org |
| Public WebSocket | wss://ws-evm.orderly.org/ws/stream/{account_id} |
| Private WebSocket | wss://ws-private-evm.orderly.org/v2/ws/private/stream/{account_id} |
{account_id} is the account ID shown on the API keys page. Symbols look like PERP_BTC_USDC, PERP_ETH_USDC, PERP_NVDA_USDC, PERP_XAU_USDC (gold) and PERP_EURUSD_USDC.
Authentication
Public market data needs no key. Every private request carries four headers:
| Header | Value |
|---|---|
orderly-account-id | Your account ID |
orderly-key | Your API key, ed25519: followed by base58 |
orderly-timestamp | The current time in milliseconds |
orderly-signature | The signature described below |
To sign a request:
- Join, with no separators: the timestamp, the HTTP method in capitals, the path including its query string, and the JSON body if there is one. For example:
1731571200000POST/v1/order{"symbol":"PERP_BTC_USDC",...} - Sign the UTF-8 bytes with your API secret (an ed25519 private key, base58).
- Encode the signature as base64url and send it as
orderly-signature.
Send Content-Type: application/json with POST and PUT, and application/x-www-form-urlencoded with GET and DELETE. Sign the exact body string you send. A timestamp more than 300 seconds away from server time is rejected, so keep your clock synced.
Keep the secret secret
The secret signs orders for your account. Load it from a secrets manager or environment variable, never commit it, and remove the key on the API keys page if it leaks. Keys cannot withdraw funds.
Python
Requires requests, base58 and cryptography.
import base64, json, os, time
import base58
import requests
from cryptography.hazmat.primitives.asymmetric.ed25519 import Ed25519PrivateKey
BASE_URL = "https://api.orderly.org"
ACCOUNT_ID = os.environ["NEXWEST_ACCOUNT_ID"]
API_KEY = os.environ["NEXWEST_API_KEY"] # ed25519:...
SECRET = base58.b58decode(os.environ["NEXWEST_API_SECRET"].removeprefix("ed25519:"))
PRIVATE_KEY = Ed25519PrivateKey.from_private_bytes(SECRET)
def signed(method, path, body=None):
payload = "" if body is None else json.dumps(body, separators=(",", ":"))
timestamp = str(int(time.time() * 1000))
signature = PRIVATE_KEY.sign(f"{timestamp}{method}{path}{payload}".encode())
headers = {
"orderly-account-id": ACCOUNT_ID,
"orderly-key": API_KEY,
"orderly-timestamp": timestamp,
"orderly-signature": base64.urlsafe_b64encode(signature).decode(),
"Content-Type": "application/json"
if method in ("POST", "PUT")
else "application/x-www-form-urlencoded",
}
response = requests.request(method, BASE_URL + path, headers=headers, data=payload or None, timeout=10)
return response.json()
print(signed("GET", "/v1/positions"))
print(signed("POST", "/v1/order", {
"symbol": "PERP_BTC_USDC",
"order_type": "POST_ONLY",
"side": "BUY",
"order_price": 60000,
"order_quantity": 0.001,
"client_order_id": "mm-btc-bid-1",
}))TypeScript
Requires @noble/curves and @scure/base. Runs on Node.js 18 or later.
import { ed25519 } from "@noble/curves/ed25519";
import { base58 } from "@scure/base";
const BASE_URL = "https://api.orderly.org";
const accountId = process.env.NEXWEST_ACCOUNT_ID!;
const apiKey = process.env.NEXWEST_API_KEY!; // ed25519:...
const secret = base58.decode(process.env.NEXWEST_API_SECRET!.replace(/^ed25519:/, ""));
type Method = "GET" | "POST" | "PUT" | "DELETE";
export async function signed(method: Method, path: string, body?: unknown) {
const payload = body === undefined ? "" : JSON.stringify(body);
const timestamp = Date.now().toString();
const message = new TextEncoder().encode(timestamp + method + path + payload);
const signature = Buffer.from(ed25519.sign(message, secret)).toString("base64url");
const response = await fetch(BASE_URL + path, {
method,
headers: {
"orderly-account-id": accountId,
"orderly-key": apiKey,
"orderly-timestamp": timestamp,
"orderly-signature": signature,
"Content-Type":
method === "POST" || method === "PUT" ? "application/json" : "application/x-www-form-urlencoded",
},
body: payload || undefined,
});
return response.json();
}
console.log(await signed("GET", "/v1/client/holding"));Responses and errors
Every response has a success flag. Successful calls return their result in data; failed calls return a code and a message:
{ "success": false, "code": -1005, "message": "order_price must be a positive number" }HTTP 429 means a rate limit was hit: wait for the next window. Authentication failures usually mean a wrong secret, a body that differs from the signed string, a missing query string in the signed path, or a clock more than 300 seconds off.
Market data
These calls need no key.
| Method | Path | Returns |
|---|---|---|
GET | /v1/public/futures | Every perpetual with mark and index price, funding rate, open interest and 24-hour volume |
GET | /v1/public/info | Trading rules per market: price and size steps, minimum order value, and margin rates (maximum leverage is 1 ÷ base_imr) |
GET | /v1/public/system_info | Whether the exchange is running or in maintenance |
For live prices, use the WebSocket streams below instead of polling.
Orders
Order calls need the read & trade permission.
| Method | Path | What it does |
|---|---|---|
POST | /v1/order | Place one order |
POST | /v1/batch-order | Place up to 10 orders: {"orders": [ ... ]} |
PUT | /v1/order | Change an open order's price or size |
DELETE | /v1/order?order_id={id}&symbol={symbol} | Cancel one order |
DELETE | /v1/batch-order?order_ids={id1},{id2} | Cancel up to 10 orders |
DELETE | /v1/orders?symbol={symbol} | Cancel all open orders in a market; leave out symbol for every market |
GET | /v1/orders?status=INCOMPLETE | Your open orders |
GET | /v1/trades | Your fills |
Fields for a new order:
| Field | Required | Notes |
|---|---|---|
symbol | Yes | For example PERP_BTC_USDC |
side | Yes | BUY or SELL |
order_type | Yes | LIMIT, MARKET, IOC, FOK, POST_ONLY, ASK or BID |
order_price | For priced orders | Not used with MARKET, ASK and BID |
order_quantity | Yes, or order_amount | Size in the base asset, up to 8 decimals |
order_amount | No | Size in USDC, for MARKET, ASK and BID orders |
client_order_id | No | Your ID, up to 36 characters, unique among your open orders, not starting with a hyphen |
reduce_only | No | true to only reduce a position |
visible_quantity | No | Size shown on the book; 0 hides the order. Not for MARKET, IOC or FOK |
post_only_adjust | No | For POST_ONLY: move the price one tick from the best price instead of rejecting |
slippage | No | For MARKET: stop filling beyond this slippage |
margin_mode | No | CROSS or ISOLATED; defaults to the market's margin mode |
To change an order, send PUT /v1/order with order_id, symbol, side, order_type, order_price and order_quantity. Prices and sizes must follow the market's steps from /v1/public/info, and the order value must reach its minimum.
Account
These calls need the read permission, except the two updates, which need read & trade.
| Method | Path | What it does |
|---|---|---|
GET | /v1/client/holding | USDC and other balances |
GET | /v1/positions | Open positions with entry price, unrealized PnL and liquidation price |
GET | /v1/client/margin_modes | Each market's margin mode |
POST | /v1/client/margin_mode | Set a market's margin mode: {"symbol": "PERP_BTC_USDC", "default_margin_mode": "ISOLATED"} |
GET | /v1/client/leverage?symbol={symbol}&margin_mode={mode} | A market's leverage for a margin mode |
POST | /v1/client/leverages | Set leverage: {"symbol": "PERP_BTC_USDC", "leverage": 10, "margin_mode": "CROSS"} |
GET | /v1/client/key_info | Your keys with their permissions, expiry and IP allow lists |
A market's margin mode can change only while it has no open positions or orders in the current mode, and leverage can change up to five times a minute.
WebSocket
Connect to the public stream for market data, or to the private stream for your account. Both use the same messages.
- Subscribe:
{"id": "book-1", "event": "subscribe", "topic": "PERP_BTC_USDC@orderbook"} - Unsubscribe: the same message with
"event": "unsubscribe". - Heartbeat: the server sends
{"event": "ping"}every 10 seconds. Answer{"event": "pong", "ts": <milliseconds>}or the connection closes.
| Stream | Topic | Pushes |
|---|---|---|
| Public | {symbol}@orderbook | The top 100 levels, every second |
| Public | {symbol}@trade | Each trade |
| Public | {symbol}@ticker | 24-hour statistics |
| Public | {symbol}@markprice | Mark price |
| Public | {symbol}@kline_1m | One-minute candles |
| Private | executionreport | Your order updates and fills; add "params": {"symbol": "PERP_BTC_USDC"} to filter |
| Private | position | Your positions |
| Private | balance | Your balances |
On the private stream, authenticate before you subscribe. Sign the timestamp alone, with the same key and base64url encoding as a REST request:
import { ed25519 } from "@noble/curves/ed25519";
import { base58 } from "@scure/base";
const accountId = process.env.NEXWEST_ACCOUNT_ID!;
const apiKey = process.env.NEXWEST_API_KEY!;
const secret = base58.decode(process.env.NEXWEST_API_SECRET!.replace(/^ed25519:/, ""));
const ws = new WebSocket(`wss://ws-private-evm.orderly.org/v2/ws/private/stream/${accountId}`);
ws.onopen = () => {
const timestamp = Date.now();
const sign = Buffer.from(ed25519.sign(new TextEncoder().encode(String(timestamp)), secret)).toString("base64url");
ws.send(JSON.stringify({ id: "auth", event: "auth", params: { orderly_key: apiKey, sign, timestamp } }));
};
ws.onmessage = (event) => {
const message = JSON.parse(String(event.data));
if (message.event === "ping") {
ws.send(JSON.stringify({ event: "pong", ts: Date.now() }));
} else if (message.event === "auth" && message.success) {
ws.send(JSON.stringify({ id: "fills", event: "subscribe", topic: "executionreport" }));
} else if (message.topic === "executionreport") {
console.log(message.data);
}
};The public stream needs no authentication: connect, then subscribe to the market topics you need.
Rate limits
Limits apply per key. Over a limit, the call gets HTTP 429.
| Call | Limit |
|---|---|
POST /v1/order | 10 a second |
POST /v1/batch-order | 1 a second, up to 10 orders; each order counts toward the order limit |
DELETE /v1/batch-order | 10 a second, up to 10 orders |
POST /v1/client/margin_mode | 10 a second |
POST /v1/client/leverages | 5 a minute |
GET /v1/client/key_info | 10 a minute |