All state-changing actions are sent to POST /exchange as signed payloads. The action.type field selects the operation.
Sign every request
The exchange endpoint rejects unsigned actions. Use an API wallet and never expose the master key to a client.
Asset IDs
- Perpetuals: the index in the
universearray frommeta. - Spot:
10000 + indexinspotMeta.universe. - Outcome markets:
20000 + index.
See assets and tick sizes for a worked example.
Place an order
/exchangeSignedWeight 4Place one or more orders. Orders in one request are matched in sequence.
Request body
| Name | Type | Required | Description |
|---|---|---|---|
orders | array | Yes | One or more order objects. |
orders[].asset | integer | Yes | Asset ID. |
orders[].isBuy | boolean | Yes | True for buy/long, false for sell/short. |
orders[].limitPx | string | Yes | Limit price; required even for market orders (use a far price). |
orders[].sz | string | Yes | Size in base units. |
orders[].reduceOnly | boolean | Yes | Prevent the order from increasing or flipping the position. |
orders[].tif | string | Yes | Gtc, Ioc, or Alo. |
orders[].cloid | string | No | 128-bit hex client order ID. |
grouping | string | Yes | na, normalTpsl, or positionTpsl. |
curl -s https://api.nexwest.app/exchange \
-H "Content-Type: application/json" \
-d '{
"action": {
"type": "order",
"orders": [{
"asset": 0,
"isBuy": true,
"limitPx": "104000",
"sz": "0.01",
"reduceOnly": false,
"tif": "Gtc"
}],
"grouping": "na"
},
"nonce": 1762732800123,
"signature": { "r": "0x...", "s": "0x...", "v": 27 }
}'const result = await nx.exchange.placeOrder({
asset: 0,
isBuy: true,
limitPx: "104000",
sz: "0.01",
reduceOnly: false,
tif: "Gtc",
});The response contains statuses with one entry per order: resting, filled, or error.
Cancel orders
/exchangeSignedWeight 2Cancel up to 100 orders by order ID.
{
"type": "cancel",
"cancels": [{ "asset": 0, "oid": 91490942 }]
}Use cancelByCloid when you track client order IDs. Use scheduleCancel to set a dead-man's switch: if no action is received before time, all open orders are canceled.
Modify an order
/exchangeSignedWeight 3Change the price or size of a resting order without losing queue priority.
Modifying an order preserves its oid but may reset time priority if the price changes. A modify that would cross the book is rejected.
Leverage and margin
| Action | Fields | Notes |
|---|---|---|
updateLeverage | asset, isCross, leverage | Leverage is an integer; cannot exceed market max |
updateIsolatedMargin | asset, isBuy, ntli | Positive adds margin, negative removes |
usdClassTransfer | n, toPerp | Move USDC between spot and perps |
subAccountTransfer | subAccountUser, usd, direction | Move USDC to or from a sub-account |
Expiry and rate limits
Some actions accept expiresAfter (milliseconds). User-signed actions such as usdClassTransfer do not. An expired action is rejected and consumes 5x the usual address weight.
Batched requests consume weight per action. See rate limits.