OKTC REST API Documentation

·

The OKTC (OKX Chain) REST API provides developers with a powerful and flexible interface to interact with the blockchain. Whether you're retrieving account balances, analyzing block data, or exploring staking and governance parameters, this documentation outlines all essential endpoints with clear request and response structures.

With a rate limit of 6 requests per second, the API ensures stable performance while supporting real-time blockchain monitoring and integration into decentralized applications (dApps). Historical queries can include a height parameter—defaulting to the latest block—though nodes may purge older data; it's recommended to query within the last 10 blocks for reliable results.

Account Information

Understanding user account states is crucial for wallet development and transaction tracking.

Get Account Balance

Retrieve the balance of all currencies associated with a specific address.

By default, only partial currency data is returned. Use show=all to display all balances or specify a single currency like symbol=btc.

HTTP Request

GET okexchain/v1/accounts/{address}

Request Parameters

Response Parameters

👉 Explore real-time account data using advanced blockchain tools

Get Account Number and Sequence

Fetch critical account metadata used in transaction signing, including account_number and sequence (nonce).

HTTP Request

GET okexchain/v1/auth/accounts/{address}

Request Parameters

Response Parameters

Block Data Queries

Access detailed block information for network analysis and synchronization checks.

Get Latest Block

Fetch the most recent block on the chain.

HTTP Request

GET okexchain/v1/blocks/latest

No parameters required.

Key Response Fields

Get Block by Height

Retrieve block details at a specific height.

HTTP Request

GET okexchain/v1/blocks/{height}

Replace {height} with the desired block number.

Response mirrors the latest block format, enabling historical analysis.

Get Transaction Info

Obtain detailed information about a transaction using its hash.

HTTP Request

GET okexchain/v1/txs/{hash}

Response Includes

👉 Monitor live transactions and validate smart contract interactions

Validator and Staking Operations

OKTC uses a delegated Proof-of-Stake model. These endpoints support staking analytics and validator monitoring.

Get Staking Parameters

Query current staking rules.

HTTP Request

GET okexchain/v1/staking/parameters

Key Parameters

Get Validator List

Retrieve all validators on the network.

HTTP Request

GET okexchain/v1/staking/validators?status=all

Response Highlights

Get Delegator Rewards

Check pending rewards across all delegations.

HTTP Request

GET okexchain/v1/distribution/delegators/{delegatorAddr}/rewards

Returns an array of rewards from each validator, plus a total sum.

Get Unbonding Delegations

Track tokens currently in the unbonding process.

HTTP Request

GET okexchain/v1/staking/delegators/{address}/unbonding_delegations

Each entry includes:

Governance Insights

Participate in on-chain governance with full transparency.

Get Proposal List

List all active and past governance proposals.

HTTP Request

GET okexchain/v1/gov/proposals

Each proposal includes:

Get Tally by Proposal ID

View real-time vote counts for a specific proposal.

HTTP Request

GET okexchain/v1/gov/proposals/{ProposalID}/tally

Output shows voting power distribution: yes, no, abstain, veto.

Get Votes by Proposal ID

See individual voter choices.

HTTP Request

GET okexchain/v1/gov/proposals/{ProposalID}/votes

Returns list of voters and their selected option.

Smart Contract Interaction (WASM)

OKTC supports WASM-based smart contracts. These APIs enable contract inspection and state querying.

Query All Contract Codes

List all uploaded contract bytecodes.

HTTP Request

GET okexchain/v1/wasm/code

Supports pagination via limit, page_key, or offset.

Query Contract by Address

Get metadata about a deployed contract.

HTTP Request

GET okexchain/v1/wasm/contract/{contractAddr}

Returns:

Smart Query Contract Data

Execute custom queries on contract state.

HTTP Request

GET okexchain/v1/wasm/contract/{contractAddr}/smart/{query}?encoding=base64

The query must be base64-encoded JSON representing the desired read operation.


Frequently Asked Questions

What is the rate limit for the OKTC REST API?

The API allows up to 6 requests per second per IP address. Exceeding this may result in temporary throttling.

How do I get a validator’s consensus key from their operator address?

Use the /staking/validators/{validatorAddr} endpoint. It returns consensus_pubkey, which is used in consensus signing.

Can I retrieve historical transaction data beyond 10 blocks?

While possible using the height parameter, nodes may have pruned old data. For long-term archives, consider running a full archival node.

How do I decode smart contract query responses?

Responses from /smart/ queries are typically Base64-encoded JSON. Decode them first, then parse as JSON to access structured data.

What does "sequence" mean in account data?

The sequence number represents the number of transactions sent from that account. It prevents replay attacks and must increment with each new transaction.

How can I track community pool distributions?

Use GET /distribution/community_pool to view the current balance of the community fund, which supports ecosystem development initiatives.

👉 Unlock advanced staking insights and governance participation tools