# Table of Contents - [Chart KLines | DMEX](#chart-klines-dmex) - [WebSocket | DMEX](#websocket-dmex) - [Create Order | DMEX](#create-order-dmex) - [Cancel Order | DMEX](#cancel-order-dmex) - [Base Tokens | DMEX](#base-tokens-dmex) - [REST | DMEX](#rest-dmex) - [General | DMEX](#general-dmex) - [General | DMEX](#general-dmex) --- # Chart KLines | DMEX [hashtag](https://docs.dmex.app/api-docs/websocket/chart-klines#chart-websocket-api) Chart WebSocket API ------------------------------------------------------------------------------------------------------------- Real-time kline (candlestick) data streaming via WebSocket. ### [hashtag](https://docs.dmex.app/api-docs/websocket/chart-klines#connection) Connection Copy ws://back.dmex.app/ws/chart ### [hashtag](https://docs.dmex.app/api-docs/websocket/chart-klines#message-format) Message Format All messages use JSON with the following structure: Copy { "type": "message_type", "data": { ... } } ### [hashtag](https://docs.dmex.app/api-docs/websocket/chart-klines#client-server-messages) Client → Server Messages #### [hashtag](https://docs.dmex.app/api-docs/websocket/chart-klines#subscribe-to-kline-stream) Subscribe to Kline Stream Subscribe to real-time candlestick updates for a symbol/interval pair. Copy { "type": "subscribeKlineStream", "data": { "symbol": "BTCUSDT", "interval": "1m" } } **Parameters:** * `symbol` - Trading pair (e.g., `BTCUSDT`, `ETHUSDT`) * `interval` - Candle interval (e.g., `1m`, `5m`, `15m`, `1h`, `4h`, `1d`) #### [hashtag](https://docs.dmex.app/api-docs/websocket/chart-klines#unsubscribe-from-kline-stream) Unsubscribe from Kline Stream Copy { "type": "unsubscribeKlineStream", "data": { "symbol": "BTCUSDT", "interval": "1m" } } #### [hashtag](https://docs.dmex.app/api-docs/websocket/chart-klines#ping) Ping Keep connection alive with application-level ping. Copy { "type": "ping", "data": null } ### [hashtag](https://docs.dmex.app/api-docs/websocket/chart-klines#server-client-messages) Server → Client Messages #### [hashtag](https://docs.dmex.app/api-docs/websocket/chart-klines#subscription-confirmed) Subscription Confirmed Sent after successful subscription. Copy { "type": "subscriptionConfirmed", "data": { "symbol": "BTCUSDT", "interval": "1m" } } #### [hashtag](https://docs.dmex.app/api-docs/websocket/chart-klines#kline-stream-update) Kline Stream Update Real-time candle data pushed to subscribed clients. Copy { "type": "klineStreamUpdate", "data": { "stream": "btcusdt_1m", "data": { "k": { "t": 1704067200000, "o": "42000.00", "h": "42150.00", "l": "41950.00", "c": "42100.00", "v": "125.5", "x": false } } } } **Candle fields (**`**k**`**):** Field Description `t` Candle open time (Unix ms) `o` Open price `h` High price `l` Low price `c` Close price `v` Volume `x` Is candle closed #### [hashtag](https://docs.dmex.app/api-docs/websocket/chart-klines#pong) Pong Response to client ping. Copy { "type": "pong", "data": null } ### [hashtag](https://docs.dmex.app/api-docs/websocket/chart-klines#example-usage-javascript) Example Usage (JavaScript) Copy const ws = new WebSocket('ws://back.dmex.app/ws/chart'); ws.onopen = () => { // Subscribe to BTC 1-minute candles ws.send(JSON.stringify({ type: 'subscribeKlineStream', data: { symbol: 'BTCUSDT', interval: '1m' } })); }; ws.onmessage = (event) => { const msg = JSON.parse(event.data); switch (msg.type) { case 'subscriptionConfirmed': console.log('Subscribed to:', msg.data.symbol, msg.data.interval); break; case 'klineStreamUpdate': const candle = msg.data.data.k; console.log('Candle update:', candle); break; case 'pong': console.log('Pong received'); break; } }; // Keep-alive ping every 30 seconds setInterval(() => { if (ws.readyState === WebSocket.OPEN) { ws.send(JSON.stringify({ type: 'ping', data: null })); } }, 30000); ### [hashtag](https://docs.dmex.app/api-docs/websocket/chart-klines#connection-management) Connection Management * **Ping/Pong**: Server sends WebSocket ping frames every 54 seconds * **Read timeout**: 60 seconds (reset on pong) * **Connection cleanup**: Stale connections removed after 120 seconds of inactivity * **Throttling**: Updates are throttled to max 1 broadcast per 300ms per symbol to prevent flooding ### [hashtag](https://docs.dmex.app/api-docs/websocket/chart-klines#multiple-subscriptions) Multiple Subscriptions You can subscribe to multiple symbol/interval pairs on a single connection: Copy // Subscribe to multiple streams ws.send(JSON.stringify({ type: 'subscribeKlineStream', data: { symbol: 'BTCUSDT', interval: '1m' } })); ws.send(JSON.stringify({ type: 'subscribeKlineStream', data: { symbol: 'BTCUSDT', interval: '5m' } })); ws.send(JSON.stringify({ type: 'subscribeKlineStream', data: { symbol: 'ETHUSDT', interval: '1m' } })); ### [hashtag](https://docs.dmex.app/api-docs/websocket/chart-klines#notes) Notes * Symbol names are case-insensitive (internally converted to lowercase) * Subscription keys are formatted as `{symbol}_{interval}` (e.g., `btcusdt_1m`) * The `stream` field in updates matches this subscription key format Last updated 1 month ago This site uses cookies to deliver its service and to analyze traffic. By browsing this site, you accept the [privacy policy](https://policies.gitbook.com/privacy/cookies) . close AcceptReject --- # WebSocket | DMEX [Create Orderchevron-right](https://docs.dmex.app/api-docs/websocket/create-order) [Cancel Orderchevron-right](https://docs.dmex.app/api-docs/websocket/cancel-order) [Chart KLineschevron-right](https://docs.dmex.app/api-docs/websocket/chart-klines) This site uses cookies to deliver its service and to analyze traffic. By browsing this site, you accept the [privacy policy](https://policies.gitbook.com/privacy/cookies) . close AcceptReject --- # Create Order | DMEX [hashtag](https://docs.dmex.app/api-docs/websocket/create-order#create-order-api) Create Order API ------------------------------------------------------------------------------------------------------- This guide explains how to programmatically create orders on the DMEX exchange. ### [hashtag](https://docs.dmex.app/api-docs/websocket/create-order#overview) Overview Orders are created by: 1. Building the order parameters 2. Generating a keccak256 hash of the order 3. Signing the hash with your private key 4. Sending the signed order via WebSocket ### [hashtag](https://docs.dmex.app/api-docs/websocket/create-order#order-parameters) Order Parameters Parameter Type Description `amount` string Order size (will be multiplied by 1e8) `price` string Order price (will be multiplied by 1e8) `side` boolean `true` = buy/long, `false` = sell/short `leverage` string Leverage multiplier (e.g., "10" for 10x) `base_token` address The margin token contract address `asset` string Trading pair symbol (e.g., "BTC", "ETH") `closing_order` boolean `true` if this order closes an existing position `stop` boolean `true` if this is a stop order `stop_price` string Trigger price for stop orders (multiplied by 1e8) `is_market` boolean `true` for market orders `post_only` boolean `true` to ensure order is maker only `replace_hash` string Hash of order to replace, or zero hash ### [hashtag](https://docs.dmex.app/api-docs/websocket/create-order#javascript-typescript-example) JavaScript/TypeScript Example Copy import { ethers } from 'ethers'; import Web3 from 'web3'; // Configuration const WS_ENDPOINT = 'wss://api.dmex.app/ws'; const BASE_TOKEN = '0x...'; // USDC or other margin token address async function createOrder({ privateKey, asset, amount, price, side, leverage, closingOrder = false, stop = false, stopPrice = '0', isMarket = false, postOnly = false, replaceHash = '' }: { privateKey: string; asset: string; amount: string; price: string; side: boolean; leverage: string; closingOrder?: boolean; stop?: boolean; stopPrice?: string; isMarket?: boolean; postOnly?: boolean; replaceHash?: string; }) { // Initialize web3 for signing const web3 = new Web3(); const account = web3.eth.accounts.privateKeyToAccount(privateKey); const userAddress = account.address; // Convert to 1e8 precision const amountScaled = (Number(amount) * 1e8).toFixed(0); const priceScaled = (Number(price) * 1e8).toFixed(0); const stopPriceScaled = (Number(stopPrice) * 1e8).toFixed(0); // Generate unique nonce const nonce = Date.now(); // Create order hash const orderHash = ethers.utils.keccak256( ethers.utils.defaultAbiCoder.encode( ['string', 'address', 'address', 'uint256', 'uint256', 'bool', 'uint256', 'uint256'], [asset, BASE_TOKEN, userAddress, amountScaled, priceScaled, side, nonce, leverage] ) ); // Sign the hash const signedData = web3.eth.accounts.sign(orderHash, privateKey); const signature = signedData.signature; // Parse signature into v, r, s const sig = signature.slice(2); const r = `0x${sig.slice(0, 64)}`; const s = `0x${sig.slice(64, 128)}`; let v = parseInt(`0x${sig.slice(128, 130)}`, 16); if (v < 27) v += 27; // Format replace_hash const formattedReplaceHash = replaceHash === '' ? '0x0000000000000000000000000000000000000000000000000000000000000000' : replaceHash; // Build order payload const order = { hash: orderHash, user_address: userAddress, base_token: BASE_TOKEN, asset: asset, amount: amountScaled, price: priceScaled, side: side, nonce: nonce, leverage: leverage, closing_order: closingOrder, v: v, r: r, s: s, remaining_amount: amountScaled, closed: false, stop: stop, stop_price: stopPriceScaled, stopped: false, is_market: isMarket, replace_hash: formattedReplaceHash, post_only: postOnly }; return order; } // Send order via WebSocket function sendOrder(ws: WebSocket, order: object) { const message = JSON.stringify({ op: 'create_order', data: order }); ws.send(message); } // Usage Example async function main() { const privateKey = '0x...'; // Your private key // Create a limit buy order for 0.1 BTC at $50,000 with 10x leverage const order = await createOrder({ privateKey, asset: 'BTC', amount: '0.1', price: '50000', side: true, // true = buy/long leverage: '10', closingOrder: false, isMarket: false, postOnly: false }); // Connect to WebSocket and send const ws = new WebSocket(WS_ENDPOINT); ws.onopen = () => { console.log('Connected'); sendOrder(ws, order); }; ws.onmessage = (event) => { const response = JSON.parse(event.data); console.log('Response:', response); }; } ### [hashtag](https://docs.dmex.app/api-docs/websocket/create-order#python-example) Python Example Copy import json import time import websocket from web3 import Web3 from eth_abi import encode # Configuration WS_ENDPOINT = 'wss://api.dmex.app/ws' BASE_TOKEN = '0x...' # USDC or other margin token address def create_order( private_key: str, asset: str, amount: str, price: str, side: bool, leverage: str, closing_order: bool = False, stop: bool = False, stop_price: str = '0', is_market: bool = False, post_only: bool = False, replace_hash: str = '' ): w3 = Web3() account = w3.eth.account.from_key(private_key) user_address = account.address # Convert to 1e8 precision amount_scaled = str(int(float(amount) * 1e8)) price_scaled = str(int(float(price) * 1e8)) stop_price_scaled = str(int(float(stop_price) * 1e8)) # Generate unique nonce nonce = int(time.time() * 1000) # Create order hash encoded = encode( ['string', 'address', 'address', 'uint256', 'uint256', 'bool', 'uint256', 'uint256'], [asset, BASE_TOKEN, user_address, int(amount_scaled), int(price_scaled), side, nonce, int(leverage)] ) order_hash = Web3.keccak(encoded).hex() # Sign the hash signed = w3.eth.account.sign_message( encode_defunct(hexstr=order_hash), private_key=private_key ) v = signed.v r = hex(signed.r) s = hex(signed.s) # Format replace_hash formatted_replace_hash = ( '0x0000000000000000000000000000000000000000000000000000000000000000' if replace_hash == '' else replace_hash ) # Build order payload order = { 'hash': order_hash, 'user_address': user_address, 'base_token': BASE_TOKEN, 'asset': asset, 'amount': amount_scaled, 'price': price_scaled, 'side': side, 'nonce': nonce, 'leverage': leverage, 'closing_order': closing_order, 'v': v, 'r': r, 's': s, 'remaining_amount': amount_scaled, 'closed': False, 'stop': stop, 'stop_price': stop_price_scaled, 'stopped': False, 'is_market': is_market, 'replace_hash': formatted_replace_hash, 'post_only': post_only } return order def send_order(ws, order): message = json.dumps({ 'op': 'create_order', 'data': order }) ws.send(message) # Usage Example if __name__ == '__main__': from eth_account.messages import encode_defunct private_key = '0x...' # Your private key # Create a limit buy order for 0.1 BTC at $50,000 with 10x leverage order = create_order( private_key=private_key, asset='BTC', amount='0.1', price='50000', side=True, # True = buy/long leverage='10', closing_order=False, is_market=False, post_only=False ) # Connect and send ws = websocket.create_connection(WS_ENDPOINT) send_order(ws, order) response = ws.recv() print('Response:', response) ws.close() ### [hashtag](https://docs.dmex.app/api-docs/websocket/create-order#order-hash-structure) Order Hash Structure The order hash is generated using `keccak256` with ABI-encoded parameters: Copy keccak256(abi.encode( asset, // string - Trading pair symbol base_token, // address - Margin token contract user_address, // address - Your wallet address amount, // uint256 - Order size * 1e8 price, // uint256 - Order price * 1e8 side, // bool - true=buy, false=sell nonce, // uint256 - Unique timestamp leverage // uint256 - Leverage multiplier )) ### [hashtag](https://docs.dmex.app/api-docs/websocket/create-order#order-types) Order Types #### [hashtag](https://docs.dmex.app/api-docs/websocket/create-order#limit-order) Limit Order Copy { is_market: false, stop: false, post_only: false // or true for maker-only } #### [hashtag](https://docs.dmex.app/api-docs/websocket/create-order#market-order) Market Order Copy { is_market: true, stop: false } #### [hashtag](https://docs.dmex.app/api-docs/websocket/create-order#stop-limit-order) Stop-Limit Order Copy { is_market: false, stop: true, stop_price: '49000' // Trigger price } #### [hashtag](https://docs.dmex.app/api-docs/websocket/create-order#stop-market-order) Stop-Market Order Copy { is_market: true, stop: true, stop_price: '49000' } ### [hashtag](https://docs.dmex.app/api-docs/websocket/create-order#closing-positions) Closing Positions To close an existing position, set `closing_order: true`. The `side` should be opposite to your current position: * To close a long position: `side: false` (sell) * To close a short position: `side: true` (buy) ### [hashtag](https://docs.dmex.app/api-docs/websocket/create-order#replacing-orders) Replacing Orders To replace an existing order, pass the hash of the order you want to cancel in `replace_hash`. This atomically cancels the old order and creates the new one. ### [hashtag](https://docs.dmex.app/api-docs/websocket/create-order#error-handling) Error Handling Common validation errors: * **Amount must be greater than zero** * **Invalid signature** - Ensure the hash is signed correctly * **Insufficient margin** - Not enough balance for the order * **Invalid leverage** - Leverage outside allowed range for the asset ### [hashtag](https://docs.dmex.app/api-docs/websocket/create-order#websocket-response) WebSocket Response Successful order creation returns: Copy { "op": "order_created", "data": { "hash": "0x...", "status": "open" } } Last updated 1 month ago This site uses cookies to deliver its service and to analyze traffic. By browsing this site, you accept the [privacy policy](https://policies.gitbook.com/privacy/cookies) . close AcceptReject --- # Cancel Order | DMEX [hashtag](https://docs.dmex.app/api-docs/websocket/cancel-order#cancel-order-api) Cancel Order API ------------------------------------------------------------------------------------------------------- Cancel an existing open order by signing its hash. ### [hashtag](https://docs.dmex.app/api-docs/websocket/cancel-order#overview) Overview Order cancellation requires: 1. The hash of the order you want to cancel 2. Signing the order hash with your private key 3. Sending the signed cancellation via WebSocket ### [hashtag](https://docs.dmex.app/api-docs/websocket/cancel-order#cancel-request-parameters) Cancel Request Parameters Parameter Type Description `order_hash` string The hash of the order to cancel `v` number Signature recovery parameter `r` string Signature r component `s` string Signature s component ### [hashtag](https://docs.dmex.app/api-docs/websocket/cancel-order#javascript-typescript-example) JavaScript/TypeScript Example Copy import Web3 from 'web3'; async function cancelOrder(privateKey: string, orderHash: string) { const web3 = new Web3(); // Sign the order hash const signedData = web3.eth.accounts.sign(orderHash, privateKey); const signature = signedData.signature; // Parse signature into v, r, s const sig = signature.slice(2); const r = `0x${sig.slice(0, 64)}`; const s = `0x${sig.slice(64, 128)}`; let v = parseInt(`0x${sig.slice(128, 130)}`, 16); if (v < 27) v += 27; return { order_hash: orderHash, v: v, r: r, s: s }; } // Send cancel request via WebSocket function sendCancelOrder(ws: WebSocket, cancelRequest: object) { const message = JSON.stringify({ op: 'cancel_order', data: cancelRequest }); ws.send(message); } // Usage Example async function main() { const privateKey = '0x...'; // Your private key const orderHash = '0x...'; // Hash of order to cancel const cancelRequest = await cancelOrder(privateKey, orderHash); const ws = new WebSocket('wss://api.dmex.app/ws'); ws.onopen = () => { sendCancelOrder(ws, cancelRequest); }; ws.onmessage = (event) => { const response = JSON.parse(event.data); console.log('Response:', response); }; } ### [hashtag](https://docs.dmex.app/api-docs/websocket/cancel-order#python-example) Python Example Copy import json import websocket from web3 import Web3 from eth_account.messages import encode_defunct def cancel_order(private_key: str, order_hash: str): w3 = Web3() # Sign the order hash signed = w3.eth.account.sign_message( encode_defunct(hexstr=order_hash), private_key=private_key ) return { 'order_hash': order_hash, 'v': signed.v, 'r': hex(signed.r), 's': hex(signed.s) } def send_cancel_order(ws, cancel_request): message = json.dumps({ 'op': 'cancel_order', 'data': cancel_request }) ws.send(message) # Usage Example if __name__ == '__main__': private_key = '0x...' # Your private key order_hash = '0x...' # Hash of order to cancel cancel_request = cancel_order(private_key, order_hash) ws = websocket.create_connection('wss://api.dmex.app/ws') send_cancel_order(ws, cancel_request) response = ws.recv() print('Response:', response) ws.close() ### [hashtag](https://docs.dmex.app/api-docs/websocket/cancel-order#notes) Notes * You can only cancel orders that you created (signature must match the original order creator) * The order must still be open (not fully filled or already cancelled) * To cancel and replace an order atomically, use the `replace_hash` parameter when creating a new order instead Last updated 1 month ago --- # Base Tokens | DMEX ### [hashtag](https://docs.dmex.app/api-docs/base-tokens#supported-base-tokens) Supported Base Tokens These are the canonical token addresses used across DMEX for each chain. #### [hashtag](https://docs.dmex.app/api-docs/base-tokens#testnet) TESTNET Address Symbol `0x0000000000000000000000000000000000000003` DEMO USD #### [hashtag](https://docs.dmex.app/api-docs/base-tokens#ethereum-eth) Ethereum (ETH) Address Symbol `0x0000000000000000000000000000000000000000` ETH `0x0000000000000000000000000000000000000001` DAI `0x0000000000000000000000000000000000000002` BTC `0x0000000000000000000000000000000000000004` USDT `0x0000000000000000000000000000000000000005` USDC `0x0000000000000000000000000000000000000006` WBTC #### [hashtag](https://docs.dmex.app/api-docs/base-tokens#polygon) Polygon Address Symbol `0x0000000000000000000000000000000000000007` MATIC `0x0000000000000000000000000000000000000008` USDT `0x0000000000000000000000000000000000000009` USDC `0x0000000000000000000000000000000000000010` WBTC #### [hashtag](https://docs.dmex.app/api-docs/base-tokens#avalanche-avax) Avalanche (AVAX) Address Symbol `0x0000000000000000000000000000000000000011` AVAX `0x0000000000000000000000000000000000000012` USDT `0x0000000000000000000000000000000000000013` USDC #### [hashtag](https://docs.dmex.app/api-docs/base-tokens#optimism) Optimism Address Symbol `0x0000000000000000000000000000000000000014` ETH `0x0000000000000000000000000000000000000015` USDT `0x0000000000000000000000000000000000000016` USDC `0x0000000000000000000000000000000000000017` WBTC #### [hashtag](https://docs.dmex.app/api-docs/base-tokens#arbitrum) Arbitrum Address Symbol `0x0000000000000000000000000000000000000018` ETH `0x0000000000000000000000000000000000000019` USDT `0x0000000000000000000000000000000000000020` USDC `0x0000000000000000000000000000000000000021` WBTC #### [hashtag](https://docs.dmex.app/api-docs/base-tokens#base) Base Address Symbol `0x0000000000000000000000000000000000000022` ETH `0x0000000000000000000000000000000000000023` USDC #### [hashtag](https://docs.dmex.app/api-docs/base-tokens#bnb-chain) BNB Chain Address Symbol `0x0000000000000000000000000000000000000025` BNB `0x0000000000000000000000000000000000000026` BUSD `0x0000000000000000000000000000000000000027` USDC #### [hashtag](https://docs.dmex.app/api-docs/base-tokens#solana) Solana Address Symbol `0x0000000000000000000000000000000000000028` SOL #### [hashtag](https://docs.dmex.app/api-docs/base-tokens#ton) TON Address Symbol `0x0000000000000000000000000000000000000029` TON `0x0000000000000000000000000000000000000030` USDT #### [hashtag](https://docs.dmex.app/api-docs/base-tokens#monero-xmr) Monero (XMR) Address Symbol `0x0000000000000000000000000000000000000031` XMR #### [hashtag](https://docs.dmex.app/api-docs/base-tokens#tron) TRON Address Symbol `0x0000000000000000000000000000000000000024` USDT `0x0000000000000000000000000000000000000032` TRX Last updated 1 month ago This site uses cookies to deliver its service and to analyze traffic. By browsing this site, you accept the [privacy policy](https://policies.gitbook.com/privacy/cookies) . close AcceptReject --- # REST | DMEX ### [hashtag](https://docs.dmex.app/api-docs/rest#authentication) Authentication All order-related endpoints require a valid signature. The signature is created by signing the order/cancel hash with the user's private key or an authorized delegate wallet. * * * ### [hashtag](https://docs.dmex.app/api-docs/rest#orders) Orders #### [hashtag](https://docs.dmex.app/api-docs/rest#get-open-orders) Get Open Orders Retrieves all open orders for a user. **Endpoint:** `GET /api/orders` **Query Parameters:** Parameter Type Required Description `user` string Yes User's Ethereum address **Example Request:** Copy GET /api/orders?user=0x1234567890abcdef1234567890abcdef12345678 **Success Response (200):** Copy { "success": true, "data": [\ {\ "hash": "0x...",\ "user_address": "0x...",\ "base_token": "0x...",\ "asset": "btcusd",\ "amount": "1000000000",\ "price": "10000000000000",\ "side": true,\ "nonce": 1234567890,\ "leverage": "1000000000",\ "closing_order": false,\ "remaining_amount": "1000000000",\ "closed": false,\ "stop": false,\ "stop_price": "0",\ "stopped": false,\ "is_market": false,\ "post_only": false,\ "decimals": 2,\ "amount_dec": 4,\ "margin_currency_symbol": "USDC",\ "created_at": "2024-01-15T10:30:00Z"\ }\ ] } #### [hashtag](https://docs.dmex.app/api-docs/rest#create-order) Create Order Creates a new trading order. **Endpoint:** `POST /api/order` **Request Body:** Copy { "hash": "0x...", "user_address": "0x...", "base_token": "0x...", "asset": "btcusd", "amount": "1000000000", "price": "10000000000000", "side": true, "nonce": 1234567890, "leverage": "1000000000", "closing_order": false, "v": 27, "r": "0x...", "s": "0x...", "remaining_amount": "1000000000", "closed": false, "stop": false, "stop_price": "0", "stopped": false, "is_market": false, "post_only": false, "decimals": 2, "amount_dec": 4, "margin_currency_symbol": "USDC", "replace_hash": "0x0000000000000000000000000000000000000000000000000000000000000000" } **Field Descriptions:** Field Type Description `hash` string Order hash (keccak256 of order parameters) `user_address` string User's Ethereum address `base_token` string Margin currency token address `asset` string Trading pair symbol (e.g., "btcusd", "ethusd") `amount` string Order amount (as string, scaled by 1e8) `price` string Order price (as string, scaled by 1e8) `side` boolean `true` = buy/long, `false` = sell/short `nonce` integer Unique nonce for the order `leverage` string Leverage amount (scaled by 1e8), `0` for cross margin `closing_order` boolean `true` if this is a reduce-only order `v`, `r`, `s` \- ECDSA signature components `remaining_amount` string Remaining unfilled amount `stop` boolean `true` if this is a stop order `stop_price` string Trigger price for stop orders `is_market` boolean `true` for market orders `post_only` boolean `true` to only add liquidity (maker only) `replace_hash` string Hash of order to replace (for order amendments) **Success Response (200):** Copy { "success": true, "message": "Order created", "data": { "hash": "0x..." } } **Error Response (400):** Copy { "success": false, "error": "Insufficient balance" } **Possible Errors:** * `Nonce too large` * `Invalid order hash - please refresh and try again` * `Invalid Signature` * `Delegate expired` * `Order with this hash already exists` * `Maximum 100 open orders allowed` * `Insufficient balance` * `Leverage too high` * `Too much leverage` * `Minimum order value is 10 USD` * `Maximum order value for this asset is X USD` * `Min acceptable price is X` * `Max acceptable price is X` * * * #### [hashtag](https://docs.dmex.app/api-docs/rest#cancel-order) Cancel Order Cancels an existing open order. **Endpoint:** `POST /api/cancel-order` **Request Body:** Copy { "order_hash": "0x...", "v": 27, "r": "0x...", "s": "0x..." } **Field Descriptions:** Field Type Description `order_hash` string Hash of the order to cancel `v`, `r`, `s` \- ECDSA signature of the order hash **Success Response (200):** Copy { "success": true, "message": "Order cancelled", "data": { "hash": "0x..." } } **Error Response (400):** Copy { "success": false, "error": "Order not found" } **Possible Errors:** * `Order not found` * `Liquidation order cannot be canceled` * `Invalid Signature` * `Delegate expired` * * * ### [hashtag](https://docs.dmex.app/api-docs/rest#trades) Trades #### [hashtag](https://docs.dmex.app/api-docs/rest#get-user-trades) Get User Trades Retrieves trade history for a user (last 100 trades). **Endpoint:** `GET /api/trades` **Query Parameters:** Parameter Type Required Description `user` string Yes User's Ethereum address **Example Request:** Copy GET /api/trades?user=0x1234567890abcdef1234567890abcdef12345678 **Success Response (200):** Copy { "success": true, "data": [\ {\ "hash": "0x...",\ "user": "0x...",\ "asset": "btcusd",\ "base_token": "0x...",\ "amount": "1000000000",\ "price": "10000000000000",\ "side": true,\ "fee": "100000",\ "created_at": "2024-01-15T10:30:00Z"\ }\ ] } * * * ### [hashtag](https://docs.dmex.app/api-docs/rest#positions) Positions #### [hashtag](https://docs.dmex.app/api-docs/rest#get-open-positions) Get Open Positions Retrieves all open positions for a user. **Endpoint:** `GET /api/positions/open` **Query Parameters:** Parameter Type Required Description `user` string Yes User's Ethereum address **Example Request:** Copy GET /api/positions/open?user=0x1234567890abcdef1234567890abcdef12345678 **Success Response (200):** Copy { "success": true, "data": [\ {\ "tx_hash": "0x...",\ "hash": "0x...",\ "base_token": "0x...",\ "asset": "btcusd",\ "side": true,\ "size": "1000000000",\ "entry_block": "12345678",\ "value": "50000000000",\ "entry_price": "10000000000000",\ "last_price": "10100000000000",\ "mark_price": 0.5,\ "liquidation_price": "9000000000000",\ "margin": "5000000000",\ "unrealized_pnl": "100000000",\ "realized_pnl": "0",\ "funding_rate": "100000",\ "decimals": 2,\ "amount_dec": 4,\ "margin_dec": 6,\ "margin_symbol": "USDC",\ "profit": "0",\ "loss": "0",\ "funding_cost": "0",\ "ur_funding_cost": "0",\ "created_at": "2024-01-15T10:30:00Z",\ "liquidated": false,\ "global_mm": 0.005,\ "is_cross": false,\ "cross_margin": "0"\ }\ ] } * * * #### [hashtag](https://docs.dmex.app/api-docs/rest#get-closed-positions) Get Closed Positions Retrieves closed positions for a user (last 100). **Endpoint:** `GET /api/positions/closed` **Query Parameters:** Parameter Type Required Description `user` string Yes User's Ethereum address **Example Request:** Copy GET /api/positions/closed?user=0x1234567890abcdef1234567890abcdef12345678 **Success Response (200):** Copy { "success": true, "data": [\ {\ "tx_hash": "0x...",\ "hash": "0x...",\ "base_token": "0x...",\ "asset": "btcusd",\ "side": true,\ "liquidated": false,\ "profit": "500000000",\ "loss": "0",\ "funding_cost": "10000000",\ "ur_funding_cost": "0",\ "created_at": "2024-01-15T10:30:00Z",\ "global_mm": 0.005,\ "decimals": 2,\ "amount_dec": 4\ }\ ] } * * * ### [hashtag](https://docs.dmex.app/api-docs/rest#binary-contracts) Binary Contracts #### [hashtag](https://docs.dmex.app/api-docs/rest#get-settled-binary-contracts) Get Settled Binary Contracts Retrieves historical settled binary contracts for a given underlying asset and contract duration. **Endpoint:** `GET /settled-binary-contracts` **Query Parameters:** Parameter Type Required Description `underlying` string Yes Underlying asset symbol (e.g., "BTCUSDT", "ETHUSDT") `contractLife` integer Yes Contract duration in minutes (e.g., 15, 60) **Example Request:** Copy GET /settled-binary-contracts?underlying=btcusd&contractLife=15 **Success Response (200):** Copy [\ {\ "symbol": "BTCUSDT-1706356800-105000-15",\ "underlying_symbol": "BTCUSDT",\ "target": 105000.00,\ "final_price": 105234.56,\ "is_above_target": true,\ "started_at": 1706356800,\ "settled_at": 1706357700\ },\ {\ "symbol": "BTCUSDT-1706355900-104500-15",\ "underlying_symbol": "BTCUSDT",\ "target": 104500.00,\ "final_price": 104123.45,\ "is_above_target": false,\ "started_at": 1706355900,\ "settled_at": 1706356800\ }\ ] **Response Field Descriptions:** Field Type Description `symbol` string Unique binary contract identifier `underlying_symbol` string The underlying asset (e.g., "BTCUSD") `target` float Strike/target price for the contract `final_price` float Settlement price at contract expiry `is_above_target` boolean `true` if final price was above target `started_at` integer Contract start time (Unix timestamp) `settled_at` integer Contract settlement time (Unix timestamp) **Error Responses:** Status Message 400 Missing required parameter: underlying 400 Missing required parameter: contractLife 400 Invalid contractLife parameter 500 Failed to fetch settled contracts * * * ### [hashtag](https://docs.dmex.app/api-docs/rest#error-handling) Error Handling All endpoints return errors in a consistent format: Copy { "success": false, "error": "Error message describing what went wrong" } **HTTP Status Codes:** Code Description 200 Success 400 Bad Request (validation error, business logic error) 405 Method Not Allowed * * * ### [hashtag](https://docs.dmex.app/api-docs/rest#notes) Notes * All `*big.Int` values are represented as strings to preserve precision * Amounts and prices are scaled by `1e8` unless otherwise specified * Timestamps are in ISO 8601 format (UTC) * Ethereum addresses and hashes should include the `0x` prefix Last updated 1 month ago --- # General | DMEX ### [hashtag](https://docs.dmex.app/api-docs/general#rest-api) REST API #### [hashtag](https://docs.dmex.app/api-docs/general#base-url) Base URL `https://back.dmex.app/` #### [hashtag](https://docs.dmex.app/api-docs/general#endpoints) Endpoints **1\. Get Candles** * **Method**: `GET` * **Path**: `/candles` * **Query Parameters**: * `symbol` (required): Asset symbol (e.g., "btcusd") * `interval` (required): Time interval ("1", "5", "15", "60", "240", "1440") * `from` (optional): Start timestamp * `to` (optional): End timestamp * `limit` (optional): Number of candles (default: 500) **Example Request**: Copy GET /candles?symbol=btcusd&interval=60&limit=100 **Response**: Copy { "s": "ok", "c": [50000, 50100, 50050], "o": [49950, 50000, 50100], "h": [50200, 50150, 50200], "l": [49900, 49980, 50000], "v": [1500, 1200, 800], "t": [1640995200, 1640998800, 1641002400] } **2\. Server Ping** * **Method**: `GET` * **Path**: `/sPing` **Response**: Copy { "status": "ok", "timestamp": 1640995200000 } **3\. Contracts** * **Method**: `GET` * **Path**: `/contracts` * **Description**: Returns all available derivative contracts **Response**: Copy [\ {\ "ticker_id": "BTC-USD",\ "base_currency": "BTC",\ "target_currency": "USD",\ "last_price": "50000.00",\ "base_volume": "150.25",\ "target_volume": "7512500.00",\ "bid": "49950.00",\ "ask": "50050.00",\ "high": "51000.00",\ "low": "49000.00",\ "product_type": "Perpetual",\ "open_interest": "1000.50",\ "open_interest_usd": "50025000.00",\ "index_price": "50000.00",\ "index_name": "BTC Index",\ "index_currency": "BTC",\ "start_timestamp": 0,\ "end_timestamp": 0,\ "funding_rate": "0.00010000",\ "next_funding_rate": "0.00010000",\ "next_funding_rate_timestamp": 1641002400,\ "contract_type": "Vanilla",\ "contract_price": "50000.00",\ "contract_price_currency": "USD"\ }\ ] **4\. Orderbook** * **Method**: `GET` * **Path**: `/orderbook` * **Query Parameters**: * `ticker_id` (required): Ticker ID (e.g., "BTC-USD") * `depth` (optional): Number of orders per side (default: 100, max: 500) **Example Request**: Copy GET /orderbook?ticker_id=BTC-USD&depth=50 **Response**: Copy { "ticker_id": "BTC-USD", "timestamp": 1640995200000, "bids": [\ ["49950.00", "1.5"],\ ["49900.00", "2.0"]\ ], "asks": [\ ["50050.00", "1.2"],\ ["50100.00", "0.8"]\ ] } * * * ### [hashtag](https://docs.dmex.app/api-docs/general#websocket-api) WebSocket API #### [hashtag](https://docs.dmex.app/api-docs/general#connection) Connection * **URL**: `wss://back.dmex.app/ws` * **Protocol**: WebSocket * **Authentication**: Required for most operations #### [hashtag](https://docs.dmex.app/api-docs/general#message-format) Message Format All WebSocket messages follow this JSON structure: Copy { "type": "message_type", "data": { // Message-specific data } } #### [hashtag](https://docs.dmex.app/api-docs/general#client-to-server-messages) Client to Server Messages **1\. Authentication** Copy { "type": "auth", "data": { "user_address": "0x1234567890abcdef...", } } **Response**: User data, balances, positions, orders, etc. **2\. Subscribe to Asset** Copy { "type": "subscribeAsset", "data": { "asset": "btcusdt" } } **Response**: Asset data, orderbook, trades **10\. Ping** Copy "ping" **Response**: Connection stays alive #### [hashtag](https://docs.dmex.app/api-docs/general#server-to-client-messages) Server to Client Messages **1\. Asset Data** Copy { "type": "assets", "data": [\ {\ "symbol": "btcusd",\ "last_price": "50000.00",\ "mark_price": 50100.00,\ "high": 51000.00,\ "low": 49000.00,\ "volume": 1500.50,\ "change": 2.5,\ "funding_rate": "0.0001",\ "open_interest": 25000000.00,\ "daily_trades": 1250\ }\ ] } **2\. User Parameters** Copy { "type": "params_user", "data": { "risk_limit": "5000", "mm_multiplier": "1.0", "fr_multiplier": "1.0", "btc_deposit_address": "bc1q...", "eth_deposit_address": "0x...", "xmr_deposit_address": "4...", "tron_deposit_address": "T...", "solana_deposit_address": "..." } } **3\. Balances** Copy { "type": "balances", "data": [\ {\ "currency": "btc",\ "available": "1.5",\ "total": "2.0",\ "reserved": "0.5"\ }\ ] } **4\. Positions** Copy { "type": "positions", "data": [\ {\ "symbol": "btcusd",\ "side": "long",\ "size": "1.5",\ "entry_price": "49500.00",\ "mark_price": "50000.00",\ "liquidation_price": "45000.00",\ "unrealized_pnl": "750.00",\ "margin": "5000.00",\ "leverage": "10",\ "margin_type": "isolated"\ }\ ] } **5\. Orders** Copy { "type": "orders", "data": [\ {\ "id": "order_hash",\ "symbol": "btcusd",\ "side": "buy",\ "amount": "1.0",\ "price": "49000.00",\ "filled": "0.5",\ "status": "open|filled|cancelled",\ "type": "limit|market",\ "timestamp": 1640995200000\ }\ ] } **6\. Trades** Copy { "type": "trades", "data": [\ {\ "symbol": "btcusd",\ "price": "50000.00",\ "amount": "0.5",\ "side": "buy",\ "timestamp": 1640995200000\ }\ ] } **7\. Orderbook** Copy { "type": "orderbook", "data": { "symbol": "btcusd", "bids": [\ ["49950.00", "1.5"],\ ["49900.00", "2.0"]\ ], "asks": [\ ["50050.00", "1.2"],\ ["50100.00", "0.8"]\ ] } } **8\. Mark Price Updates** Copy { "type": "mark_price", "data": { "symbol": "btcusd", "price": 50125.50, "timestamp": 1640995200000 } } **9\. Funding Rate Updates** Copy { "type": "funding_rate", "data": { "symbol": "btcusd", "funding_rate": "0.0001" } } **10\. Error Messages** Copy { "type": "error", "data": { "message": "Error description" } } **11\. Success Messages** Copy { "type": "success", "data": { "message": "Operation successful" } } * * * ### [hashtag](https://docs.dmex.app/api-docs/general#authentication) Authentication #### [hashtag](https://docs.dmex.app/api-docs/general#websocket-authentication) WebSocket Authentication 1. Connect to WebSocket endpoint 2. Send authentication message with user address and unique ID 3. Server validates and responds with user data #### [hashtag](https://docs.dmex.app/api-docs/general#message-signing) Message Signing For sensitive operations (orders, withdrawals, margin updates), messages must be signed: * **hash**: Keccak256 hash of message data * **v**: Recovery ID (27 or 28) * **r**: First 32 bytes of signature * **s**: Last 32 bytes of signature * **user**: User's Ethereum address * * * ### [hashtag](https://docs.dmex.app/api-docs/general#rate-limiting) Rate Limiting #### [hashtag](https://docs.dmex.app/api-docs/general#global-limits) Global Limits * **Global**: 1000 requests per second with burst of 5000 * **Per IP**: 1 request per second with burst of 5 #### [hashtag](https://docs.dmex.app/api-docs/general#connection-limits) Connection Limits * **Max connections per user**: 5 * **Max total connections**: Configurable via environment #### [hashtag](https://docs.dmex.app/api-docs/general#rate-limit-headers) Rate Limit Headers Rate limit information is not exposed in headers but enforced server-side. * * * ### [hashtag](https://docs.dmex.app/api-docs/general#error-handling) Error Handling #### [hashtag](https://docs.dmex.app/api-docs/general#websocket-errors) WebSocket Errors Copy { "type": "error", "data": { "message": "Error description" } } #### [hashtag](https://docs.dmex.app/api-docs/general#http-errors) HTTP Errors * **400 Bad Request**: Invalid parameters * **404 Not Found**: Endpoint or resource not found * **429 Too Many Requests**: Rate limit exceeded * **500 Internal Server Error**: Server error #### [hashtag](https://docs.dmex.app/api-docs/general#common-error-messages) Common Error Messages * `"Invalid wallet"`: Authentication failed * `"Too Many Requests"`: Rate limit exceeded * `"Ticker not found"`: Invalid asset symbol * `"SERVER MAX ALLOWED CONNECTIONS REACHED"`: Connection limit exceeded * `"Invalid Signature"`: Message signature validation failed * * * ### [hashtag](https://docs.dmex.app/api-docs/general#data-types) Data Types #### [hashtag](https://docs.dmex.app/api-docs/general#precision) Precision * **Prices**: Stored as big integers with 1e8 precision * **Amounts**: Stored as big integers with asset-specific precision * **Funding Rates**: Stored as big integers with 1e16 precision #### [hashtag](https://docs.dmex.app/api-docs/general#timestamps) Timestamps * **WebSocket**: Unix timestamps in milliseconds * **REST**: Unix timestamps in seconds or milliseconds (endpoint-specific) #### [hashtag](https://docs.dmex.app/api-docs/general#asset-symbols) Asset Symbols * Format: `{base}usd` (e.g., "btcusd", "ethusd") * Case-insensitive but returned in lowercase #### [hashtag](https://docs.dmex.app/api-docs/general#order-sides) Order Sides * `"buy"` or `"sell"` #### [hashtag](https://docs.dmex.app/api-docs/general#order-types) Order Types * `"limit"`: Limit order * `"market"`: Market order #### [hashtag](https://docs.dmex.app/api-docs/general#margin-types) Margin Types * `"isolated"`: Isolated margin * `"cross"`: Cross margin #### [hashtag](https://docs.dmex.app/api-docs/general#order-status) Order Status * `"open"`: Active order * `"filled"`: Completely filled * `"cancelled"`: Cancelled order * `"partially_filled"`: Partially filled Last updated 1 month ago --- # General | DMEX ### [hashtag](https://docs.dmex.app/api-docs#rest-api) REST API #### [hashtag](https://docs.dmex.app/api-docs#base-url) Base URL `https://back.dmex.app/` #### [hashtag](https://docs.dmex.app/api-docs#endpoints) Endpoints **1\. Get Candles** * **Method**: `GET` * **Path**: `/candles` * **Query Parameters**: * `symbol` (required): Asset symbol (e.g., "btcusd") * `interval` (required): Time interval ("1", "5", "15", "60", "240", "1440") * `from` (optional): Start timestamp * `to` (optional): End timestamp * `limit` (optional): Number of candles (default: 500) **Example Request**: Copy GET /candles?symbol=btcusd&interval=60&limit=100 **Response**: Copy { "s": "ok", "c": [50000, 50100, 50050], "o": [49950, 50000, 50100], "h": [50200, 50150, 50200], "l": [49900, 49980, 50000], "v": [1500, 1200, 800], "t": [1640995200, 1640998800, 1641002400] } **2\. Server Ping** * **Method**: `GET` * **Path**: `/sPing` **Response**: Copy { "status": "ok", "timestamp": 1640995200000 } **3\. Contracts** * **Method**: `GET` * **Path**: `/contracts` * **Description**: Returns all available derivative contracts **Response**: Copy [\ {\ "ticker_id": "BTC-USD",\ "base_currency": "BTC",\ "target_currency": "USD",\ "last_price": "50000.00",\ "base_volume": "150.25",\ "target_volume": "7512500.00",\ "bid": "49950.00",\ "ask": "50050.00",\ "high": "51000.00",\ "low": "49000.00",\ "product_type": "Perpetual",\ "open_interest": "1000.50",\ "open_interest_usd": "50025000.00",\ "index_price": "50000.00",\ "index_name": "BTC Index",\ "index_currency": "BTC",\ "start_timestamp": 0,\ "end_timestamp": 0,\ "funding_rate": "0.00010000",\ "next_funding_rate": "0.00010000",\ "next_funding_rate_timestamp": 1641002400,\ "contract_type": "Vanilla",\ "contract_price": "50000.00",\ "contract_price_currency": "USD"\ }\ ] **4\. Orderbook** * **Method**: `GET` * **Path**: `/orderbook` * **Query Parameters**: * `ticker_id` (required): Ticker ID (e.g., "BTC-USD") * `depth` (optional): Number of orders per side (default: 100, max: 500) **Example Request**: Copy GET /orderbook?ticker_id=BTC-USD&depth=50 **Response**: Copy { "ticker_id": "BTC-USD", "timestamp": 1640995200000, "bids": [\ ["49950.00", "1.5"],\ ["49900.00", "2.0"]\ ], "asks": [\ ["50050.00", "1.2"],\ ["50100.00", "0.8"]\ ] } * * * ### [hashtag](https://docs.dmex.app/api-docs#websocket-api) WebSocket API #### [hashtag](https://docs.dmex.app/api-docs#connection) Connection * **URL**: `wss://back.dmex.app/ws` * **Protocol**: WebSocket * **Authentication**: Required for most operations #### [hashtag](https://docs.dmex.app/api-docs#message-format) Message Format All WebSocket messages follow this JSON structure: Copy { "type": "message_type", "data": { // Message-specific data } } #### [hashtag](https://docs.dmex.app/api-docs#client-to-server-messages) Client to Server Messages **1\. Authentication** Copy { "type": "auth", "data": { "user_address": "0x1234567890abcdef...", } } **Response**: User data, balances, positions, orders, etc. **2\. Subscribe to Asset** Copy { "type": "subscribeAsset", "data": { "asset": "btcusdt" } } **Response**: Asset data, orderbook, trades **10\. Ping** Copy "ping" **Response**: Connection stays alive #### [hashtag](https://docs.dmex.app/api-docs#server-to-client-messages) Server to Client Messages **1\. Asset Data** Copy { "type": "assets", "data": [\ {\ "symbol": "btcusd",\ "last_price": "50000.00",\ "mark_price": 50100.00,\ "high": 51000.00,\ "low": 49000.00,\ "volume": 1500.50,\ "change": 2.5,\ "funding_rate": "0.0001",\ "open_interest": 25000000.00,\ "daily_trades": 1250\ }\ ] } **2\. User Parameters** Copy { "type": "params_user", "data": { "risk_limit": "5000", "mm_multiplier": "1.0", "fr_multiplier": "1.0", "btc_deposit_address": "bc1q...", "eth_deposit_address": "0x...", "xmr_deposit_address": "4...", "tron_deposit_address": "T...", "solana_deposit_address": "..." } } **3\. Balances** Copy { "type": "balances", "data": [\ {\ "currency": "btc",\ "available": "1.5",\ "total": "2.0",\ "reserved": "0.5"\ }\ ] } **4\. Positions** Copy { "type": "positions", "data": [\ {\ "symbol": "btcusd",\ "side": "long",\ "size": "1.5",\ "entry_price": "49500.00",\ "mark_price": "50000.00",\ "liquidation_price": "45000.00",\ "unrealized_pnl": "750.00",\ "margin": "5000.00",\ "leverage": "10",\ "margin_type": "isolated"\ }\ ] } **5\. Orders** Copy { "type": "orders", "data": [\ {\ "id": "order_hash",\ "symbol": "btcusd",\ "side": "buy",\ "amount": "1.0",\ "price": "49000.00",\ "filled": "0.5",\ "status": "open|filled|cancelled",\ "type": "limit|market",\ "timestamp": 1640995200000\ }\ ] } **6\. Trades** Copy { "type": "trades", "data": [\ {\ "symbol": "btcusd",\ "price": "50000.00",\ "amount": "0.5",\ "side": "buy",\ "timestamp": 1640995200000\ }\ ] } **7\. Orderbook** Copy { "type": "orderbook", "data": { "symbol": "btcusd", "bids": [\ ["49950.00", "1.5"],\ ["49900.00", "2.0"]\ ], "asks": [\ ["50050.00", "1.2"],\ ["50100.00", "0.8"]\ ] } } **8\. Mark Price Updates** Copy { "type": "mark_price", "data": { "symbol": "btcusd", "price": 50125.50, "timestamp": 1640995200000 } } **9\. Funding Rate Updates** Copy { "type": "funding_rate", "data": { "symbol": "btcusd", "funding_rate": "0.0001" } } **10\. Error Messages** Copy { "type": "error", "data": { "message": "Error description" } } **11\. Success Messages** Copy { "type": "success", "data": { "message": "Operation successful" } } * * * ### [hashtag](https://docs.dmex.app/api-docs#authentication) Authentication #### [hashtag](https://docs.dmex.app/api-docs#websocket-authentication) WebSocket Authentication 1. Connect to WebSocket endpoint 2. Send authentication message with user address and unique ID 3. Server validates and responds with user data #### [hashtag](https://docs.dmex.app/api-docs#message-signing) Message Signing For sensitive operations (orders, withdrawals, margin updates), messages must be signed: * **hash**: Keccak256 hash of message data * **v**: Recovery ID (27 or 28) * **r**: First 32 bytes of signature * **s**: Last 32 bytes of signature * **user**: User's Ethereum address * * * ### [hashtag](https://docs.dmex.app/api-docs#rate-limiting) Rate Limiting #### [hashtag](https://docs.dmex.app/api-docs#global-limits) Global Limits * **Global**: 1000 requests per second with burst of 5000 * **Per IP**: 1 request per second with burst of 5 #### [hashtag](https://docs.dmex.app/api-docs#connection-limits) Connection Limits * **Max connections per user**: 5 * **Max total connections**: Configurable via environment #### [hashtag](https://docs.dmex.app/api-docs#rate-limit-headers) Rate Limit Headers Rate limit information is not exposed in headers but enforced server-side. * * * ### [hashtag](https://docs.dmex.app/api-docs#error-handling) Error Handling #### [hashtag](https://docs.dmex.app/api-docs#websocket-errors) WebSocket Errors Copy { "type": "error", "data": { "message": "Error description" } } #### [hashtag](https://docs.dmex.app/api-docs#http-errors) HTTP Errors * **400 Bad Request**: Invalid parameters * **404 Not Found**: Endpoint or resource not found * **429 Too Many Requests**: Rate limit exceeded * **500 Internal Server Error**: Server error #### [hashtag](https://docs.dmex.app/api-docs#common-error-messages) Common Error Messages * `"Invalid wallet"`: Authentication failed * `"Too Many Requests"`: Rate limit exceeded * `"Ticker not found"`: Invalid asset symbol * `"SERVER MAX ALLOWED CONNECTIONS REACHED"`: Connection limit exceeded * `"Invalid Signature"`: Message signature validation failed * * * ### [hashtag](https://docs.dmex.app/api-docs#data-types) Data Types #### [hashtag](https://docs.dmex.app/api-docs#precision) Precision * **Prices**: Stored as big integers with 1e8 precision * **Amounts**: Stored as big integers with asset-specific precision * **Funding Rates**: Stored as big integers with 1e16 precision #### [hashtag](https://docs.dmex.app/api-docs#timestamps) Timestamps * **WebSocket**: Unix timestamps in milliseconds * **REST**: Unix timestamps in seconds or milliseconds (endpoint-specific) #### [hashtag](https://docs.dmex.app/api-docs#asset-symbols) Asset Symbols * Format: `{base}usd` (e.g., "btcusd", "ethusd") * Case-insensitive but returned in lowercase #### [hashtag](https://docs.dmex.app/api-docs#order-sides) Order Sides * `"buy"` or `"sell"` #### [hashtag](https://docs.dmex.app/api-docs#order-types) Order Types * `"limit"`: Limit order * `"market"`: Market order #### [hashtag](https://docs.dmex.app/api-docs#margin-types) Margin Types * `"isolated"`: Isolated margin * `"cross"`: Cross margin #### [hashtag](https://docs.dmex.app/api-docs#order-status) Order Status * `"open"`: Active order * `"filled"`: Completely filled * `"cancelled"`: Cancelled order * `"partially_filled"`: Partially filled Last updated 1 month ago This site uses cookies to deliver its service and to analyze traffic. By browsing this site, you accept the [privacy policy](https://policies.gitbook.com/privacy/cookies) . close AcceptReject ---