Logo
RPC Assistant

What is the Ethereum blockchain API and which provider should you use?

Summary

The Ethereum blockchain API allows applications to read data and send transactions to the Ethereum network. It typically uses JSON-RPC over HTTP or WebSocket, and includes methods for querying balances, sending transactions, and interacting with smart contracts. Developers can either run their own node or use an RPC provider to access the API without managing infrastructure. When choosing a provider, consider factors like request limits, latency, archive data support, and WebSocket availability. Services like OnFinality offer scalable RPC endpoints for Ethereum mainnet and testnets, with options for dedicated nodes.

Ethereum Blockchain API Decision Checklist

Before integrating an Ethereum API, evaluate these criteria to choose the right approach:

CriterionWhat to checkWhy it matters
Request rate limitsFree tier requests per second (RPS) and daily capHigh-throughput dApps need higher limits to avoid throttling
Node typeFull node vs. archive nodeArchive nodes support historical state queries; full nodes only recent data
Trace/Parity API supportAvailability of trace_ or debug_ methodsRequired for analytics, block explorers, and MEV applications
WebSocket supportWSS endpoint for real-time subscriptionsEssential for monitoring events, mempool, and price feeds
Uptime and redundancySLA commitment, multi-region failoverProduction apps need reliable infrastructure
Supported networksMainnet, testnets (Sepolia, Holesky), and L2sEnsure coverage for your deployment targets
Pricing modelPay-as-you-go vs. subscriptionFree tiers suit development; paid plans needed for scale
Security & authenticationAPI key management, encryptionPrevent unauthorized access and data leaks

What Is an Ethereum Blockchain API?

An Ethereum blockchain API is an interface that allows your application to communicate with the Ethereum network without running a local node. It exposes methods to read blockchain data (balances, blocks, transactions) and submit new transactions. The standard protocol for Ethereum APIs is JSON-RPC, a lightweight remote procedure call protocol that uses JSON as its data format.

There are two main types of Ethereum APIs:

  • Node APIs (JSON-RPC): Direct methods exposed by Ethereum clients like Geth or Nethermind. These require a node to be running but give full access to all RPC methods.
  • Explorer APIs (e.g., Etherscan): Provide higher-level endpoints for account balances, token transfers, and contract events. They are easier to use but limited to data available on the explorer.

Most production dApps use a node API via an RPC provider to avoid managing infrastructure. This article focuses on the JSON-RPC API and how to select a provider.

How the Ethereum JSON-RPC API Works

Every Ethereum execution client implements the JSON-RPC specification. The API defines a set of methods classified into three categories:

  • Gossip methods: eth_blockNumber, eth_sendRawTransaction
  • State methods: eth_getBalance, eth_call, eth_getStorageAt
  • History methods: eth_getTransactionReceipt, eth_getLogs

A typical JSON-RPC request looks like this:

curl -X POST https://eth-mainnet.g.alchemy.com/v2/YOUR_KEY \
  -H "Content-Type: application/json" \
  -d '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":1}'

Response:

{"jsonrpc":"2.0","id":1,"result":"0x10d4f3b"}

Ethereum APIs also support WebSocket for real-time streaming. For example, subscribing to new pending transactions:

const WebSocket = require('ws');
const ws = new WebSocket('wss://eth-mainnet.g.alchemy.com/v2/YOUR_KEY');
ws.on('open', function open() {
  ws.send(JSON.stringify({jsonrpc:'2.0', id:1, method:'eth_subscribe', params:['newPendingTransactions']}));
});
ws.on('message', function incoming(data) {
  console.log(data);
});

Running Your Own Node vs Using an RPC Provider

Deploying a dApp means deciding how to access the Ethereum API. Two primary options exist:

Running a Full Node

  • Pros: Full control, clear rate limits, direct access to database.
  • Cons: Requires 1TB+ SSD, syncing takes days, ongoing maintenance, and high bandwidth costs.

Using an RPC Provider

  • Pros: Instant access, scalable, no maintenance, often includes WebSocket and archive nodes.
  • Cons: Vendor dependency, potential rate limits, and cost at scale.

Most teams choose a hybrid approach: use a provider for production while keeping a local node for debugging. For protocols requiring historical data or high throughput, a dedicated node from a provider like OnFinality offers isolated resources without shared rate limits.

What to Look for in an Ethereum API Provider

When evaluating providers for your Ethereum API needs, consider these factors:

1. Supported Methods

Not all providers support every JSON-RPC method. Archive methods like eth_getStorageAt for old blocks, or trace_replayTransaction for parity-style tracing, are often restricted. If your dApp needs them, verify availability.

2. WebSocket Support

Real-time features such as mempool monitoring or event listening require a WebSocket endpoint. Check that the provider offers WSS connections and its subscription stability.

3. Redundancy and Uptime

A single-node endpoint is a single point of failure. Providers that operate multiple geographically distributed nodes with automatic failover provide higher reliability. For production dApps, a dedicated node with an SLA gives you predictable performance.

4. Request Limits

Free tiers often cap requests per second (e.g., 10-100 RPS) and daily volume. If your dApp grows, ensure the provider's paid plans scale to your needs without architectural changes.

5. Network Coverage

Beyond mainnet, you may need testnets like Sepolia or L2 networks like Arbitrum and Optimism. Some providers offer unified endpoints for multiple chains via a single API key.

6. Pricing Transparency

Some providers charge per request, others per compute unit. Compare based on your usage pattern. For high-volume apps, a fixed monthly plan for a dedicated node may be more economical.

OnFinality provides flexible pricing for RPC endpoints, including dedicated nodes for Ethereum mainnet and testnets. You can see the full list of supported networks on our networks page and check RPC pricing for details.

Common Ethereum API Methods and Examples

Here are the most frequently used Ethereum JSON-RPC methods:

MethodDescriptionEndpoint type
eth_blockNumberGet the latest block numberGossip
eth_getBalanceGet native ETH balanceState
eth_callExecute a read-only smart contract callState
eth_sendRawTransactionSubmit a signed transactionGossip
eth_getTransactionReceiptGet receipt for a confirmed transactionHistory
eth_getLogsFilter events by address/topicsHistory
eth_subscribeSubscribe to events or new blocksWebSocket

Example: Getting Account Balance with ethers.js

import { ethers } from 'ethers';

const provider = new ethers.providers.JsonRpcProvider(
  'https://eth-mainnet.g.alchemy.com/v2/YOUR_KEY'
);

async function getBalance(address) {
  const balance = await provider.getBalance(address);
  console.log(`Balance: ${ethers.utils.formatEther(balance)} ETH`);
}

getBalance('0xab5801a7d398351b8be11c439e05c5b3259aec9b');

Example: Querying Historical Events

const filter = {
  address: '0x...',
  fromBlock: 1000000,
  toBlock: 1000100,
  topics: [ethers.utils.id('Transfer(address,address,uint256)')],
};
const logs = await provider.getLogs(filter);
console.log(logs);

Key Takeaways

  • The Ethereum blockchain API is primarily JSON-RPC, allowing direct interaction with nodes.
  • You can run your own node or use an RPC provider; providers offer instant setup, scalability, and redundancy.
  • When selecting a provider, evaluate request limits, method support, WebSocket availability, and pricing.
  • For production, consider dedicated nodes to avoid shared rate limits and gain performance isolation.
  • OnFinality offers Ethereum mainnet and testnet RPC endpoints, both shared and dedicated, with transparent pricing.

FAQ

Q: Do I need an API key to use the Ethereum blockchain API? A: Public nodes like the Ethereum Foundation's mainnet endpoints exist but are rate-limited and unreliable for production. Most RPC providers require an API key, which is free for low usage.

Q: What is the difference between a full node and an archive node API? A: Full nodes only store the latest state and recent blocks. Archive nodes store all historical states, enabling queries like eth_getBalance for any block. Archive nodes are more expensive but necessary for some use cases.

Q: Can I use the same API for Ethereum L2s like Arbitrum? A: L2s have their own RPC endpoints that implement a similar JSON-RPC specification, but methods may differ slightly. Some providers offer unified access across multiple chains with a single key.

Q: How do I handle rate limiting in production? A: Use multiple endpoints with load balancing, upgrade to a higher tier, or switch to a dedicated node. OnFinality's dedicated nodes provide private resources without shared limits.

Q: Is it possible to switch providers without changing my dApp code? A: Most dApps use the ethers.js or web3.js library, which abstracts the RPC endpoint. Changing the provider URL in your configuration is usually sufficient, provided the new provider supports the same methods.

For more guidance on selecting the right infrastructure, see our How to Choose an RPC Provider guide.

RPC Knowledge Base

Related RPC details

Never Worry about Infrastructure Again

OnFinality takes away the heavy lifting of DevOps so you can build smarter and faster.

Get Started