Get Transaction Status | API Reference

·

Understanding the status of a blockchain transaction is crucial for developers building decentralized applications, especially when integrating cross-chain or single-chain swaps. This guide dives deep into how to retrieve the final transaction status of a swap using the txhash via the OKX DEX API. Whether you're debugging, verifying user transactions, or building a real-time dashboard, this endpoint provides all the critical data you need.

We’ll walk through the request structure, parameters, response fields, and practical use cases—ensuring you can seamlessly integrate and interpret transaction data with confidence.


How to Retrieve Transaction Status Using txHash

The Get Transaction Status API endpoint allows developers to fetch detailed information about a specific swap transaction on a supported blockchain. By providing the transaction hash (txHash) and chain identifier, you can monitor whether a swap is pending, successful, or failed.

This is particularly useful in environments where user experience depends on accurate, real-time feedback—such as decentralized exchanges (DEXs), portfolio trackers, or automated trading bots.

👉 Check live transaction status with powerful Web3 tools

Request Endpoint

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

This secure, public endpoint returns structured JSON data containing full transaction metadata.


Required and Optional Request Parameters

To successfully query a transaction, you must include specific parameters. Here's what’s needed:

🔹 chainIndex (String, Required)

A unique identifier for the blockchain network. For example:

For a complete list of supported chains, refer to the official chain index documentation.

🔹 chainId (String, Required – Deprecated Soon)

An alternative chain identifier following EIP-155 standards. Note: This field will be deprecated in future versions. Developers are encouraged to use chainIndex for long-term compatibility.

🔹 txHash (String, Required)

The transaction hash generated when a swap was initiated via the OKX DEX API. This 64-character hexadecimal string uniquely identifies the transaction on-chain.

🔘 isFromMyProject (Boolean, Optional)

Use this flag to filter results:

This adds an extra layer of security and traceability for projects managing multiple integrations.


Understanding the Response Parameters

Once the request is processed, the API returns a comprehensive JSON object detailing every aspect of the transaction. Below is a breakdown of each response field.

📦 Core Transaction Data

🧾 Address Information

💱 Token Swap Details

fromTokenDetails

An array containing details about the input token:

toTokenDetails

Details of the output token:

⚙️ Fee and Gas Metrics

These values help assess cost efficiency and network congestion:

❗ Error Handling


Practical Use Cases

Real-Time Swap Tracking Dashboard

Developers can build UIs that poll this endpoint periodically to show users:

Automated Reconciliation Systems

Finance teams or audit tools can use this API to:

Bot Monitoring & Recovery Logic

Trading bots can implement retry logic:

👉 Explore advanced transaction monitoring features


Frequently Asked Questions (FAQ)

Q: What’s the difference between chainIndex and chainId?
A: chainIndex is OKX’s internal standardized ID system. chainId follows Ethereum’s EIP-155 standard but will be deprecated soon. Always prefer chainIndex.

Q: Can I check transactions not made through my API key?
A: Yes—by omitting isFromMyProject or setting it to false, you can query any transaction processed by OKX DEX API.

Q: How often should I poll this endpoint?
A: For optimal performance, poll once every 10–15 seconds during active confirmation. Avoid excessive polling to prevent rate limiting.

Q: Why do some fields show base units instead of human-readable amounts?
A: To maintain precision across blockchains, amounts are returned in the smallest denomination (e.g., wei). Convert using 10^decimals.

Q: Is there a rate limit for this API?
A: Yes—standard rate limits apply based on your API key tier. Check your usage dashboard to avoid throttling.

Q: How soon after submission can I query a transaction?
A: You can query immediately after broadcast. If not found, it may still be propagating—wait a few seconds before retrying.


Sample Request & Response

While actual examples are not included here due to formatting constraints, typical usage involves sending an HTTP GET request with query parameters:

GET https://web3.okx.com/api/v5/dex/aggregator/history?chainIndex=1&txHash=0xabc123...&isFromMyProject=true

Expected response includes structured JSON with all relevant fields populated according to the transaction state.

👉 Access full API documentation and test endpoints instantly


Best Practices for Integration

  1. Always validate status before proceeding—never assume success based on broadcast alone.
  2. Use webhooks or event listeners where possible to reduce polling overhead.
  3. Log errorMsg and txHash for debugging failed transactions.
  4. Normalize token amounts using known decimals for display purposes.
  5. Monitor gas metrics over time to optimize future transactions.

By leveraging this API effectively, developers gain full visibility into swap operations—enhancing reliability, transparency, and user trust in their applications.