Skip to main content

Place Trading Orders

Execute trading orders on supported exchanges. Each exchange has its own endpoint with specific requirements.

Supported Exchanges

ExchangeEndpointSymbol FormatNotes
AsterPOST /api/trading/aster/ordersBTCUSDTRequires x-wallet-id header
HyperliquidPOST /api/trading/hyperliquid/ordersBTCRequires x-wallet-id header
LighterPOST /api/trading/lighter/ordersUSDCRequires API credentials as query params
Lighter DEX Requirement: Before using Lighter, you must:
  1. Create an account on Lighter DEX
  2. Deposit funds on Lighter
  3. Generate API keys from Lighter dashboard
  4. Provide credentials as query parameters

Aster - Place Order

Execute orders on Aster exchange for perpetual futures trading.

Endpoint

POST /api/aster/perp/:walletId/order

Path Parameters

ParameterTypeRequiredDescription
walletIdstringYesWallet ID (UUID)

Request Body

{
  "symbol": "BTCUSDT",
  "side": "BUY",
  "type": "MARKET",
  "quantity": "0.001",
  "positionSide": "BOTH"
}

Request Parameters

FieldTypeRequiredDescription
symbolstringYesTrading pair (e.g., “BTCUSDT”)
sidestringYes”BUY” (open LONG/close SHORT) or “SELL” (open SHORT/close LONG)
typestringYesOrder type: “MARKET”, “LIMIT”, “STOP_MARKET”, “TAKE_PROFIT_MARKET”
quantitystringYesBase asset quantity
pricestringNoRequired for LIMIT orders
positionSidestringNo”BOTH” (one-way mode, default), “LONG”, or “SHORT” (hedge mode)
reduceOnlybooleanNoPrevent increasing exposure
timeInForcestringNo”GTC” (default), “IOC”, or “FOK”

Order Types

  • MARKET - Execute immediately at best price
  • LIMIT - Execute only at specified price
  • STOP_MARKET - Stop loss (market execution)
  • TAKE_PROFIT_MARKET - Take profit (market execution)

Position Sides

  • BOTH - One-way mode (default) - single position per symbol
  • LONG - Long position (hedge mode)
  • SHORT - Short position (hedge mode)

Time in Force

  • GTC - Good Till Cancel (default)
  • IOC - Immediate or Cancel
  • FOK - Fill or Kill

Example Request

curl -X POST https://api.dexaggregatorbeta.xyz/api/aster/perp/ee337309-3e77-4278-b21a-4681468168ba/order \
  -H "Content-Type: application/json" \
  -d '{
    "symbol": "BTCUSDT",
    "side": "BUY",
    "type": "MARKET",
    "quantity": "0.001",
    "positionSide": "BOTH"
  }'

Success Response

{
  "success": true,
  "data": {
    "orderId": 9884649221,
    "symbol": "BTCUSDT",
    "status": "NEW",
    "clientOrderId": "6D52PQwRlg0PcdHz5ttkgN",
    "price": "0",
    "avgPrice": "0.0000",
    "origQty": "0.001",
    "executedQty": "0",
    "cumQty": "0",
    "cumQuote": "0",
    "timeInForce": "GTC",
    "type": "MARKET",
    "reduceOnly": false,
    "closePosition": false,
    "side": "BUY",
    "positionSide": "BOTH",
    "stopPrice": "0",
    "workingType": "CONTRACT_PRICE",
    "priceProtect": false,
    "origType": "MARKET",
    "updateTime": 1764640797006
  }
}

Hyperliquid - Place Order

Execute orders on Hyperliquid exchange for perpetual futures trading.

Endpoint

POST /api/trading/hyperliquid/orders

Headers

HeaderValueRequired
x-wallet-idWallet ID (UUID)Yes
Content-Typeapplication/jsonYes

Request Body

{
  "userId": "a1e82339-29f8-41a6-a468-ce8d268a3261",
  "symbol": "BTC",
  "side": "SELL",
  "type": "MARKET",
  "quantity": "0.01",
  "price": "87131.0",
  "reduceOnly": false
}

Request Parameters

FieldTypeRequiredDescription
userIdstringYesUser’s wallet ID or address
symbolstringYesAsset symbol (e.g., “BTC”, “ETH”, “HYPE”)
sidestringYes”BUY” or “SELL”
typestringYes”MARKET” or “LIMIT”
quantitystringYesBase asset quantity
pricestringYesPrice for the order
reduceOnlybooleanNoPrevent increasing exposure (default: false)
Hyperliquid uses simple asset symbols like BTC, ETH, HYPE. The price field should be provided for both MARKET and LIMIT orders.

Example Request

curl -X POST https://api.dexaggregatorbeta.xyz/api/trading/hyperliquid/orders \
  -H "x-wallet-id: a1e82339-29f8-41a6-a468-ce8d268a3261" \
  -H "Content-Type: application/json" \
  -d '{
    "userId": "a1e82339-29f8-41a6-a468-ce8d268a3261",
    "symbol": "BTC",
    "side": "SELL",
    "type": "MARKET",
    "quantity": "0.01",
    "price": "87131.0",
    "reduceOnly": false
  }'

Success Response

{
  "success": true,
  "data": {
    "orderId": "255730787458",
    "status": "FILLED",
    "symbol": "BTC",
    "side": "SELL",
    "type": "MARKET",
    "price": "87131.0",
    "quantity": "0.01",
    "filledQuantity": "0.00157",
    "timestamp": 1764688069312
  },
  "timestamp": 1764688069314
}

Lighter - Place Order

Execute orders on Lighter DEX using API credentials from your Lighter account.

Endpoint

POST /api/trading/lighter/orders

Query Parameters (Required)

These credentials must be obtained from your Lighter DEX account dashboard.
ParameterTypeRequiredDescription
apiKeyPrivateKeystringYesYour Lighter API key private key (hex format)
apiKeyIndexnumberYesAPI key index from Lighter
accountIndexnumberYesYour Lighter account index

Full Example URL

POST /api/trading/lighter/orders?apiKeyPrivateKey=539ef81cacb...&apiKeyIndex=5&accountIndex=316225

Request Body

{
  "userId": "0x07943f0f79097572451601e768c329a2765f2ea2",
  "symbol": "USDC",
  "side": "BUY",
  "type": "MARKET",
  "quantity": "1.1",
  "price": "1",
  "reduceOnly": true
}

Request Parameters

FieldTypeRequiredDescription
userIdstringYesUser’s wallet address
symbolstringYesToken symbol (e.g., “USDC”)
sidestringYes”BUY” or “SELL”
typestringYes”MARKET” or “LIMIT”
quantitystringYesBase asset quantity
pricestringNoRequired for LIMIT orders
reduceOnlybooleanNoPrevent increasing exposure
Lighter uses spot token symbols like “USDC”. Quantity is in base asset units.

Example Request

curl -X POST "https://api.dexaggregatorbeta.xyz/api/trading/lighter/orders?apiKeyPrivateKey=539ef81cacb...&apiKeyIndex=5&accountIndex=316225" \
  -H "Content-Type: application/json" \
  -d '{
    "userId": "0x07943f0f79097572451601e768c329a2765f2ea2",
    "symbol": "USDC",
    "side": "BUY",
    "type": "MARKET",
    "quantity": "1.1",
    "price": "1",
    "reduceOnly": true
  }'

Success Response

{
  "success": true,
  "orderId": "948233341",
  "status": "submitted",
  "adapter": "lighter",
  "timestamp": 1698840000000
}

Error Responses

400 Bad Request - Missing Parameters

{
  "success": false,
  "error": "Missing required parameters",
  "timestamp": 1698840000000
}

400 Bad Request - Invalid Order Type

{
  "success": false,
  "error": "Invalid order type. Must be MARKET or LIMIT",
  "timestamp": 1698840000000
}

401 Unauthorized - Missing Wallet ID

{
  "success": false,
  "error": "Missing x-wallet-id header",
  "timestamp": 1698840000000
}

403 Forbidden - Invalid API Credentials (Lighter)

{
  "success": false,
  "error": "Invalid API credentials",
  "timestamp": 1698840000000
}

500 Internal Server Error

{
  "success": false,
  "error": "Failed to place order",
  "timestamp": 1698840000000
}

Order Types

Market Orders

Execute immediately at the best available price.
{
  "type": "MARKET",
  "quantity": "0.1"
}

Limit Orders

Execute only at the specified price or better.
{
  "type": "LIMIT",
  "quantity": "0.1",
  "price": "50000"
}

Important Notes

Lighter API Credentials: Never expose your Lighter API credentials in client-side code. Always make requests from your secure backend server.
Wallet ID Header: For Aster and Hyperliquid, you must include the x-wallet-id header with your server wallet ID.
Reduce Only: Set reduceOnly: true to ensure orders only close existing positions and don’t open new ones.
Symbol Formats:
  • Aster: BTCUSDT, ETHUSDT
  • Hyperliquid: BTC, ETH, HYPE (simple asset symbols)
  • Lighter: USDC, USDT