API Quickstart
REST base URL: https://api.trade8.xyz. WebSocket base URL: wss://ws.trade8.xyz, connection path /v1.
This walkthrough reads contract specifications, prepares a signed order, and follows its execution. Identifiers, prices, fees, and limits in examples are illustrative.
Try the Public Catalog
Section titled “Try the Public Catalog”Read contract specifications before setting up credentials:
curl --fail-with-body 'https://api.trade8.xyz/v1/markets/BTC-PERP'curl --fail-with-body 'https://api.trade8.xyz/v1/venues?type=decentralized'The response includes a catalog revision and capture time. See Markets and Exchange Contracts for filters and price rules.
1. Load Credentials
Section titled “1. Load Credentials”An approved trading account supplies a key ID, secret, account grants, and permissions. Load the key ID and base64 secret into TRADE8_API_KEY and TRADE8_API_SECRET from your secret manager.
Download the Node.js Helper or Python Helper into your server project. These are small source examples using standard libraries. Read the signing format before adapting them.
2. Read Markets and Accounts
Section titled “2. Read Markets and Accounts”Market specifications are public. Account reads require accounts:read; the helper signs those requests using your credentials.
import { request } from './rest-client.mjs';
const markets = await request('GET', '/v1/markets?instrument=BTC-PERP&limit=50');console.log(markets.markets);
const accounts = await request('GET', '/v1/accounts?limit=50');console.log(accounts.accounts.map(account => ({ id: account.account_id, exchanges: account.enabled_venues,})));from rest_client import request
markets = request("GET", "/v1/markets?instrument=BTC-PERP&limit=50")print(markets["markets"])
accounts = request("GET", "/v1/accounts?limit=50")for account in accounts["accounts"]: print(account["account_id"], account["enabled_venues"])Each market includes its exchange contracts. Binance’s BTCUSDT settles in USDT and Hyperliquid’s BTC settles in USDC. Check tick size, quantity step, margin capability, and settlement asset before submitting an order.
Use the returned account ID in account requests. Confirm balances, fee rates, and account limits before enabling an execution process.
3. Submit a Limit Order
Section titled “3. Submit a Limit Order”This example buys 0.100 BTC with a limit of 77,000 USDT. Routing is restricted to Binance and Bybit contracts settled in USDT. post_only requests maker execution. Running this code with an enabled account submits an order.
import { request } from './rest-client.mjs';
const order = { account_id: 'acct_example_main', client_order_id: 'strategy-a-0001', instrument: 'BTC-PERP', settlement_asset: 'USDT', side: 'buy', type: 'limit', quantity: '0.100', limit_price: '77000.00', time_in_force: 'GTC', post_only: true, reduce_only: false, routing: 'auto', venue_policy: { allowed: ['binance', 'bybit'] }, self_trade_prevention: 'cancel_newest',};
const accepted = await request('POST', '/v1/orders', order, 'order-request-0001');console.log(accepted.order_id, accepted.status);Persist the client order ID and idempotency key before submission. Use a new pair for a new order. After a timeout, reconcile the original order as described in Requests and Recovery.
4. Read Fills
Section titled “4. Read Fills”const accountId = 'acct_example_main';const orderId = 'ord_example_01';const result = await request('GET', `/v1/orders/${encodeURIComponent(orderId)}/fills?account_id=${encodeURIComponent(accountId)}&limit=50`);for (const fill of result.fills) { console.log(fill.venue, fill.quantity, fill.price, fill.fee, fill.fee_asset);}The Order Lifecycle explains partial fills, final quantities, and cancellation. The REST Reference includes request fields and response schemas for every operation.
5. Subscribe to an Exchange Book
Section titled “5. Subscribe to an Exchange Book”Public channels require no key:
const socket = new WebSocket('wss://ws.trade8.xyz/v1');socket.addEventListener('open', () => socket.send(JSON.stringify({ op: 'subscribe', id: 'btc-book', channel: 'orderbook', instrument: 'BTC-PERP', venue: 'hyperliquid', settlement_asset: 'USDC', depth: 20,})));socket.addEventListener('message', event => console.log(JSON.parse(event.data)));For heartbeat, reconnect, and sequence handling, use the WebSocket Guide. The Channel Reference covers market data, orders, fills, positions, balances, risk, collateral, and settlements.