Creating a Limit Order: API Reference Guide

ยท

Overview

A limit order is an essential trading tool that allows users to buy or sell assets at predetermined prices on decentralized exchanges (DEX). This guide provides a detailed walkthrough of the API endpoint for creating limit orders.


API Endpoint

POST https://web3.okx.com/api/v5/dex/aggregator/limit-order/save-order


Request Parameters

ParameterTypeRequiredDescription
orderHashStringYesUnique identifier for the order
signatureStringYesCryptographic signature for verification
chainIdStringYesBlockchain network ID (e.g., 1 for Ethereum)
Data ObjectObjectYesOrder details
saltStringYesRandom nonce for idempotency (timestamp in seconds)
makingAmountStringYesAmount of token sold (with decimals, e.g., 1000000 for 1.00 USDT)
takingAmountStringYesAmount of token bought (with decimals)
makerTokenStringYesContract address of the sold token
takerTokenStringYesContract address of the bought token
makerStringYesWallet address creating the order
deadLineStringYesOrder expiration timestamp (seconds)
allowedSenderStringYesAddress permitted to execute the order (0x00... for open execution)
receiverStringYesDestination address for assets
minReturnStringYesMinimum acceptable return amount
partiallyAbleBoolYesWhether partial order fulfillment is allowed

Response Parameters

ParameterTypeDescription
codeStringStatus code (e.g., 0 for success)
msgStringServer response message

Usage Scenarios

  1. Token Swaps: Execute precise trades at specified rates.
  2. Partial Fills: Enable partial order fulfillment for liquidity efficiency.
  3. Expiry Control: Set deadlines to manage order validity periods.

๐Ÿ‘‰ Learn advanced DEX strategies here


FAQs

What is a limit order?

A limit order specifies the maximum/minimum price at which you're willing to buy/sell an asset.

How do decimals work in amounts?

Token amounts must include decimal precision (e.g., 1000000 = 1.00 USDT).

Can I restrict order execution?

Yes, via allowedSenderโ€”set to 0x00... for open access or a specific address for restricted execution.

๐Ÿ‘‰ Explore API integrations


Best Practices

This guide adheres to Web3 security standards while optimizing for DEX trading efficiency.