Querying Transaction Status in OKX DEX API

·

Overview

The OKX DEX API provides a method to check the final transaction status of cross-chain swaps using the transaction hash (txHash). This feature is essential for developers and traders to monitor and verify the completion of their decentralized exchange transactions.


API Endpoint

GET https://web3.okx.com/api/v5/dex/aggregator/history


Request Parameters

ParameterTypeRequiredDescription
chainIndexStringYesUnique chain identifier (e.g., 1 for Ethereum). Refer to supported chains.
chainIdStringYesDeprecated. Use chainIndex instead.
txHashStringYesTransaction hash generated via OKX DEX API.
isFromMyProjectBooleanNoSet to true to filter transactions initiated by your API key. Default: false.

Response Parameters

ParameterTypeDescription
chainIdStringChain identifier (e.g., 1 for Ethereum).
txHashStringTransaction hash.
heightStringBlock height of the transaction.
txTimeStringTransaction timestamp (Unix epoch in milliseconds).
statusStringpending (executing), success (completed), fail (reverted).
txTypeStringTransaction type: Approve, Wrap, Unwrap, Swap.
fromAddressStringSender's wallet address.
dexrouterStringContract address interacted with.
toAddressStringRecipient's wallet address.
fromTokenDetailsArrayDetails of the input token:
> symbolStringToken symbol (e.g., ETH).
> amountStringAmount in smallest unit (e.g., wei for ETH).
> tokenAddressStringToken contract address.
toTokenDetailsArrayDetails of the output token (same structure as above).
referalAmountStringReferral commission amount.
errorMsgStringError message (if any).
gasLimitStringGas limit.
gasUsedStringGas consumed (in smallest unit).
gasPriceStringGas price (in smallest unit).
txFeeStringTransaction fee in native token.

Example Request

curl -X GET "https://web3.okx.com/api/v5/dex/aggregator/history?chainIndex=1&txHash=0x123..."

Example Response

{
  "chainId": "1",
  "txHash": "0x123...",
  "status": "success",
  "txType": "Swap",
  "fromTokenDetails": {
    "symbol": "ETH",
    "amount": "1000000000000000000",
    "tokenAddress": "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE"
  },
  "toTokenDetails": {
    "symbol": "USDC",
    "amount": "1500000000",
    "tokenAddress": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48"
  }
}

FAQs

1. How long does it take to get a transaction status?

Transactions typically update within seconds, but delays may occur during network congestion.

2. What does pending status mean?

It indicates the transaction is still being processed on-chain. Monitor until it changes to success or fail.

3. Can I query transactions from other projects?

Only if isFromMyProject=false (default). For project-specific queries, set it to true.

👉 Explore more about OKX DEX API