Summary
Ethereum APIs include the standard JSON-RPC methods (eth_*), the Beacon REST API for consensus data, and the Engine API used internally by clients. Provider-specific endpoints like Etherscan's or Alchemy's are not standard Ethereum APIs. This guide helps you identify what counts as an Ethereum API and how to connect reliably.
Quick Answer: What Counts as an Ethereum API?
When someone asks "which of these are Ethereum APIs?", the answer depends on whether you mean the standardized interfaces defined by the Ethereum protocol or the extra endpoints that infrastructure providers add on top. The core Ethereum APIs are:
- Execution JSON-RPC (the
eth_*methods) – used to read state, send transactions, and interact with smart contracts. - Beacon REST API – exposes consensus-layer data like slots, validators, and finality.
- Engine API – the internal interface between execution and consensus clients, not meant for external use.
Provider-specific endpoints like Etherscan's ?module=account&action=balance or Alchemy's alchemy_getAssetTransfers are not Ethereum APIs in the protocol sense. They are convenience services built on top of the blockchain. Understanding this distinction helps you choose the right interface for your application and avoid vendor lock-in.
Decision Guide: Which API Should You Use?
Before you write any code, decide which API layer matches your use case. Use this table to evaluate your options:
| Use Case | Recommended API | Why |
|---|---|---|
| Reading balances, sending transactions, calling contracts | Execution JSON-RPC | The standard interface supported by all clients and providers |
| Querying validator activity, finality, or beacon chain data | Beacon REST API | Provides consensus-layer data not available via eth_* |
| Real-time updates (new blocks, pending transactions) | WebSocket JSON-RPC | Enables subscriptions like eth_subscribe |
| Historical state or logs beyond default pruning | Archive node JSON-RPC | Required for eth_getBalance at old blocks or eth_getLogs over long ranges |
| Provider-specific features (token balances, NFT metadata) | Provider APIs (e.g., Etherscan, Alchemy) | Not standard, but can save development time |
For most dApps, you'll start with the Execution JSON-RPC over HTTPS. If you need real-time data, add a WebSocket connection. If you're building analytics or a block explorer, you'll likely need archive access and possibly the Beacon REST API.
What Is the Ethereum JSON-RPC API?
The Ethereum JSON-RPC API is a set of methods that allow clients to interact with the Ethereum network. It follows the JSON-RPC 2.0 specification and is implemented by all major execution clients (Geth, Nethermind, Besu, Erigon). Methods fall into three categories:
- Gossip methods:
eth_sendRawTransaction,eth_sendTransaction– broadcast transactions to the network. - State methods:
eth_getBalance,eth_call,eth_getStorageAt– read the current state. - History methods:
eth_getBlockByNumber,eth_getTransactionReceipt,eth_getLogs– query historical data.
Here's a simple curl example to get the latest block number:
curl -X POST https://eth-mainnet.rpc.onfinality.io \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":1}'
The Beacon REST API: Consensus Data
After The Merge, Ethereum has two layers: execution and consensus. The Beacon REST API exposes consensus-layer data, such as:
GET /eth/v1/beacon/genesis– genesis informationGET /eth/v1/beacon/states/{state_id}/validators– validator setGET /eth/v1/beacon/blocks/{block_id}– beacon block details
This API is useful for staking dashboards, validator monitoring, and applications that need finality information. It's not a replacement for JSON-RPC; it complements it.
The Engine API: Internal Communication
The Engine API is a JSON-RPC interface between the execution client and the consensus client. It handles block validation and payload execution. It's not meant for external developers and is rarely exposed publicly. If you see an endpoint labeled "Engine API," it's likely for internal node operations, not for dApp development.
Provider-Specific APIs: Not Standard Ethereum
Services like Etherscan, Alchemy, and Infura offer their own APIs that go beyond the standard JSON-RPC. For example:
- Etherscan API:
https://api.etherscan.io/api?module=account&action=balance&address=0x...– returns balances, transaction history, and contract ABIs. - Alchemy NFT API:
alchemy_getNFTMetadata– fetches NFT data. - Infura IPFS API: not Ethereum-specific but offered alongside.
These are not Ethereum APIs. They are proprietary extensions that can be convenient, but they introduce a dependency on a specific provider. If you build on them, migrating to another provider may require code changes.
How to Connect: Using Libraries and Endpoints
Instead of raw curl, most developers use libraries like ethers.js or viem. Here's an example using viem:
import { createPublicClient, http } from 'viem';
import { mainnet } from 'viem/chains';
const client = createPublicClient({
chain: mainnet,
transport: http('https://eth-mainnet.rpc.onfinality.io'),
});
const blockNumber = await client.getBlockNumber();
console.log('Current block number:', blockNumber);
When choosing an RPC provider, consider:
- Method support: Does it support
eth_getLogs,eth_call, and archive methods? - Rate limits: What are the requests per second and daily caps?
- WebSocket support: Needed for real-time subscriptions.
- Redundancy: Does the provider use load-balanced nodes?
OnFinality offers public and dedicated RPC endpoints for Ethereum and many other networks. Check our RPC pricing and supported networks for details.
Common Pitfalls and How to Avoid Them
- Using provider-specific methods without fallback: If you rely on
alchemy_getAssetTransfers, your app breaks if you switch providers. Stick to standard methods when possible. - Ignoring block parameter:
eth_getBalancerequires a block parameter. Using"latest"may not give historical data; use"earliest"or a specific block number. - Assuming all providers support archive data: Not all do. If you need historical state, verify archive support.
- Forgetting WebSocket for real-time: HTTP is request-response; WebSocket allows subscriptions. Use
eth_subscribefor pending transactions.
Key Takeaways
- The standard Ethereum APIs are Execution JSON-RPC, Beacon REST, and Engine API.
- Provider-specific APIs are not Ethereum APIs; they are proprietary extensions.
- Choose your API based on your use case: state, history, real-time, or consensus data.
- Use libraries like viem or ethers.js to simplify development.
- Evaluate RPC providers on method support, rate limits, WebSocket, and archive data.
Frequently Asked Questions
Is Etherscan API an Ethereum API?
No, Etherscan API is a proprietary API that provides data from the Ethereum blockchain. It's not part of the standard Ethereum API set.
What is the difference between JSON-RPC and REST API?
JSON-RPC is a protocol that uses JSON for remote procedure calls, typically over HTTP or WebSocket. REST is an architectural style. Ethereum's standard API is JSON-RPC, not REST.
Can I use WebSocket for Ethereum API?
Yes, many providers offer WebSocket endpoints for real-time subscriptions. Use eth_subscribe to listen for new blocks or pending transactions.
Do I need an API key for Ethereum API?
Public endpoints may not require a key, but for production, you'll want a managed service with an API key to get higher rate limits and reliability.
What is an archive node?
An archive node stores the full state history, allowing queries at any past block. It's necessary for analytics and historical data.
Next Steps
Now that you know which APIs are Ethereum APIs, you can start building. If you need a reliable RPC provider, explore OnFinality's API service or consider a dedicated node for high-throughput applications. For a broader view, see our guide to choosing an RPC provider.