How to Connect to OKX Onchain Market API? Token Identification and Price Verification

 / 
OKX
 / 
2

The challenge of connecting to OKX Onchain Market API is not technical, but rather billing and authentication. All requests require signing. After the free quota is used up, you pay per call, and payment is only supported in USDG or USDT on the X Layer network. The core issues of token identification and price verification are: how to use the correct parameters to get the correct token, and how to judge whether the price you get is trustworthy.

OKX Exchange
A leading global cryptocurrency platform,suitable for both beginners and experienced traders.
New user benefit: 20% off trading fees upon registration!!

Preparation Before Connecting

You first need to create a project on the OKX Onchain OS developer platform to obtain four credentials: OKX_API_KEY, OKX_SECRET_KEY, OKX_API_PASSPHRASE, and OKX_PROJECT_ID. Each request must include OK-ACCESS-KEY, OK-ACCESS-SIGN, OK-ACCESS-PASSPHRASE, and OK-ACCESS-TIMESTAMP in the Header.

Signature verification failure is the most common connection error. 50113 Invalid signature usually means the query parameters are not serialized correctly. OKX's signature requires deterministic parameter sorting. If you don't want to handle signatures manually, the official TypeScript SDK (okx-dex-market-sdk) encapsulates the signature logic and all endpoints.

Billing Rules: When You Start Paying

The Market API uses tiered pricing. All API Key holders get a monthly free quota: the Basic tier includes 100,000 free calls. After the free quota is exhausted, each call costs $0.0001 on Basic and $0.0002 on Premium.

Payment is only supported in USDG or USDT on the X Layer network, settled via the x402 pay-per-call model. A few endpoints are completely free, such as /api/v6/dex/market/supported/chain and /api/v6/dex/balance/supported/chain.

If you are just doing prototype validation or low-frequency queries, the free quota is usually sufficient. Once you enter production with high-frequency polling, payment is inevitable.

Token Identification: Address and Chain are the Unique Identifiers

The OKX Onchain API does not identify tokens by token name or symbol. Chain ID (chainIndex) + Contract Address (tokenContractAddress) is the unique identifier.

chainIndex is OKX's own chain identifier system: Ethereum is 1, Solana is 501, BSC is 56. Passing the wrong chain ID will return 50038 Unsupported chain.

Contract addresses on EVM chains must be in all lowercase. If you copy an address from elsewhere that contains uppercase letters, you need to convert it first, otherwise the request will fail.

If you want to search for tokens by name, use the marketTokenSearch endpoint, but search results may return multiple tokens with the same name. You must confirm which one you want based on the contract address. For meme tokens, the market/memepump/tokenDetails endpoint can return data such as creator address, Top 10 holder percentage, Dev holder percentage, and Bundlers percentage. This is key information for judging token risk.

Price Verification: Two Price Sources for Different Purposes

OKX provides two price sources for different purposes.

Market Price aggregates onchain DEX trading activity and centralized exchange quotes, reflecting the token's "real market price." It updates quickly and is suitable for real-time monitoring and trading decisions. The WebSocket price-info channel pushes at most once per second, including price, market cap, 5-minute to 24-hour price changes, transaction count, and liquidity. The regular price channel only pushes when there is a trade and the price is not filtered by the K-line filter.

Index Price is a composite price calculated from multiple independent third-party sources (CEX, DEX, oracles), designed to resist price distortion from a single source. If you need a manipulation-resistant reference price—for example, setting stop-loss thresholds or calculating risk parameters—use Index Price instead of Market Price.

When verifying whether a price is trustworthy, check three things: whether the returned time timestamp is close to the current time, whether liquidity is sufficient (prices of low-liquidity tokens are easily manipulated), and whether volume24H matches the price movement. If a small-cap token suddenly shows a large price change with extremely low volume, the price is likely not trustworthy.

Common Connection Failures

50105 Incorrect PASSPHRASE: Check whether OK-ACCESS-PASSPHRASE matches the one set when creating the API Key.

50113 Invalid signature: The most common cause is incorrect parameter serialization order. Using the official SDK can avoid this problem.

50011 Rate limit triggered: The RPS limit for trial tiers is usually 1-5, which can only be increased after upgrading. Control request frequency or implement exponential backoff retry.

50038 Unsupported chain: Check whether chainIndex is correct. Do not use chain names (like "ethereum"); use numeric identifiers.

50404 URL not found: Confirm the endpoint path is spelled correctly. v6 endpoints are different from v5.

OKX Exchange
A leading global cryptocurrency platform,suitable for both beginners and experienced traders.
New user benefit: 20% off trading fees upon registration!!

References

  1. OKX Wallet·Market API Fee | Guides | Market | Onchain OS Documentation, page not dated; verified on: 2026-10-06.
  2. NPM·okx-dex-market-sdk, page published or updated on: 2025-09-24; verified on: 2026-10-06.
  3. okx.pro·Advanced price channel | Websocket Channels | Guides | Market | Onchain OS Documentation, page not dated; verified on: 2026-10-06.
  4. OKX Wallet·Error Codes | Onchain Basic Data API | Market | Onchain OS Documentation, page not dated; verified on: 2026-10-06.
  5. OKX Wallet·API Fee | Overview | Home | Onchain OS Documentation, page not dated; verified on: 2026-10-06.
  6. okx.pro·Get Single Token Scan Information | Scan API Reference | Strategy API | Market | Onchain OS Documentation, page not dated; verified on: 2026-10-06.
  7. okx.pro·Building with AI | Guides | Market | Onchain OS Documentation, page not dated; verified on: 2026-10-06.
  8. OKX Wallet·Price Channel | Websocket Channels | Websocket | Guides | Market | Onchain OS Documentation, page not dated; verified on: 2026-10-06.