Summary
The Kaia API is the JSON-RPC interface for the Kaia blockchain, an EVM-compatible Layer 1 network. It lets you read chain data, send transactions, and interact with smart contracts using familiar Ethereum-style methods. This guide explains the API namespaces, how to connect via public or managed endpoints, and how to choose the right infrastructure for your dApp.
Quick recommendation: Which Kaia API access mode fits your project?
Before you write any code, decide how you will reach the Kaia network. The right choice depends on your workload, not on which provider has the most documentation.
- Prototyping or a hackathon: use a public endpoint. It is free and fine for low-volume testing, but it is shared and can be rate-limited or unstable under load.
- A production dApp or backend service: use a managed RPC provider. You get dedicated throughput, higher reliability, and support for WebSocket and archive data. OnFinality offers a managed Kaia RPC service with public and dedicated options.
- Heavy data indexing or analytics: you likely need archive node access and a provider that supports large historical queries. Check whether the provider offers archive data and what the pricing looks like on RPC pricing.
If you are still evaluating providers, the table in the next section gives you the criteria that matter most.
What is the Kaia API?
Kaia is a public, EVM-compatible Layer 1 blockchain created from the merger of Klaytn and Finschia. It is designed for high performance with one-second block times, low transaction fees, and instant finality, making it suitable for large-scale Web3 and stablecoin applications.
The Kaia API is the JSON-RPC interface that lets you interact with the Kaia network. If you have worked with Ethereum's JSON-RPC APIs, the interface will feel familiar. You can use it to read blockchain data, send transactions, and call smart contract methods.
Kaia exposes several API namespaces:
- Ethereum-compatible namespaces:
eth_,net_,web3_– standard methods likeeth_blockNumber,eth_getBalance,eth_call, andeth_sendRawTransaction. - Kaia-specific namespaces:
kaia_– methods that extend the Ethereum API with Kaia-specific features, such askaia_getBlockByNumberandkaia_getTransactionReceipt. - Legacy
klay_namespace: maintained for backward compatibility with the old Klaytn API. It supports the same operations askaia_but with theklay_prefix. - Debug namespace:
debug_– development and debugging utilities for deep blockchain analysis and transaction inspection.
For a complete list of supported methods, refer to the official Kaia documentation.
Kaia chain settings at a glance
When you configure a wallet or a dApp to connect to Kaia, you need the correct chain parameters. Here are the essential settings for the Kaia mainnet:
| Parameter | Value |
|---|---|
| Network Name | Kaia Mainnet |
| Chain ID | 8217 |
| Native Currency | KAIA (symbol: KAIA, decimals: 18) |
| Block Explorer | Kaiascope |
| Public RPC Endpoint | https://klaytn.api.onfinality.io/public |
These settings are also available on the Kaia network page.
How to connect to the Kaia API
You can connect to the Kaia API using any Ethereum-compatible library, such as ethers.js, viem, or web3.js. Here is a simple example using ethers.js:
import { JsonRpcProvider } from 'ethers';
const provider = new JsonRpcProvider('https://klaytn.api.onfinality.io/public');
async function getBlockNumber() {
const blockNumber = await provider.getBlockNumber();
console.log('Latest block:', blockNumber);
}
getBlockNumber();
You can also make raw JSON-RPC requests with curl:
curl -X POST https://klaytn.api.onfinality.io/public \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":1}'
For WebSocket support, you can use a WebSocket endpoint if your provider offers one. OnFinality's managed Kaia endpoints support both HTTP and WebSocket, which is useful for real-time applications like price feeds or transaction monitoring.
Kaia API methods: what you can do
Kaia's API is broad. Here are the most common method groups you will use:
- Chain information:
eth_chainId,eth_blockNumber,eth_gasPrice - Account queries:
eth_getBalance,eth_getTransactionCount,eth_getCode - Smart contract interaction:
eth_call,eth_sendRawTransaction,eth_getTransactionReceipt - Block queries:
eth_getBlockByNumber,eth_getBlockByHash - Kaia-specific:
kaia_getBlockByNumber,kaia_getTransactionReceipt,kaia_call - Debug:
debug_traceTransaction,debug_traceBlockByNumber
For a full reference, see the Kaia JSON-RPC API docs.
How to choose a Kaia RPC provider
When you move beyond a public endpoint, you need to evaluate RPC providers. Here is a comparison table to guide your decision:
| Criterion | What to check | Why it matters |
|---|---|---|
| Throughput and rate limits | Does the provider offer dedicated throughput or shared limits? | High-traffic dApps need consistent performance without sudden rate limiting. |
| Reliability and uptime | What is the provider's historical uptime? Do they have a status page? | Downtime directly impacts your users and can cause failed transactions. |
| Archive data | Does the provider support archive requests? | Indexers and analytics tools often need historical state. |
| WebSocket support | Is WSS available for real-time subscriptions? | Essential for applications that need live updates. |
| Geographic distribution | Where are the provider's nodes located? | Global edge networks reduce latency for users worldwide. |
| Pricing model | Is it pay-as-you-go, subscription, or usage-based? | Predictable costs help you scale without surprises. |
| Support and SLAs | What level of support is offered? | Production apps need responsive support when issues arise. |
OnFinality is a strong option for Kaia RPC. We offer a managed Kaia endpoint with both public and dedicated nodes, and you can see our pricing for details. Our infrastructure is designed for production workloads, with global edge nodes and support for WebSocket and archive data.
Common pitfalls and how to avoid them
Even with a good provider, you can run into issues. Here are some common pitfalls when working with the Kaia API:
- Using the wrong chain ID: Make sure you use
8217for Kaia mainnet and1001for the Kairos testnet. Using the wrong chain ID will cause transactions to fail. - Rate limiting on public endpoints: Public endpoints are shared, so they can be rate-limited. If you see
429errors, consider moving to a managed provider. - Not handling WebSocket reconnections: If you use WebSocket, implement reconnection logic to handle network drops.
- Assuming all methods are available: Some providers may not support debug or archive methods. Check your provider's documentation.
- Ignoring gas price fluctuations: Kaia has low fees, but gas price can still vary. Use
eth_gasPriceor a gas estimator to avoid stuck transactions.
Debugging Kaia API calls
When something goes wrong, here is a quick debugging path:
- Check the endpoint: Verify that you are using the correct URL and that it is reachable.
- Check the chain ID: Ensure your requests include the correct chain ID.
- Test with a simple method: Start with
eth_blockNumberto confirm basic connectivity. - Inspect error messages: JSON-RPC errors include a code and message. Common codes are
-32601(method not found) and-32000(server error). - Use a block explorer: If a transaction fails, look it up on Kaiascope to see the revert reason.
If you are using OnFinality, you can also check our network status page for any ongoing incidents.
Key Takeaways
- The Kaia API is an Ethereum-compatible JSON-RPC interface for the Kaia blockchain.
- Use the correct chain ID (
8217for mainnet) and endpoint for your network. - Public endpoints are fine for testing, but production apps should use a managed RPC provider like OnFinality.
- Evaluate providers based on throughput, reliability, archive data, WebSocket support, and pricing.
- Debug systematically: check endpoint, chain ID, and method availability before diving deeper.
Frequently Asked Questions
What is the Kaia API?
The Kaia API is the JSON-RPC interface for the Kaia blockchain, allowing developers to interact with the network using Ethereum-compatible methods.
What is the Kaia chain ID?
The Kaia mainnet chain ID is 8217. The Kairos testnet uses 1001.
Is the Kaia API free?
Public endpoints are free but have rate limits. For production use, you will likely need a paid managed RPC service.
Can I use ethers.js with Kaia?
Yes, Kaia is EVM-compatible, so you can use ethers.js, viem, web3.js, and other Ethereum libraries.
Does OnFinality support Kaia?
Yes, OnFinality provides a managed Kaia RPC endpoint. You can find more details on the Kaia network page.