Ankr provides RPC access to Ethereum, allowing developers to interact with the ETH mainnet and testnets via standard JSON-RPC calls. This guide explains how to obtain and use Ankr RPC ETH endpoints, authenticate requests, and integrate them into your applications. It covers endpoint formats, common methods, and practical considerations for reliable performance.
What Is Ankr RPC for Ethereum?
Ankr is a blockchain infrastructure provider that offers Remote Procedure Call (RPC) services for multiple networks, including Ethereum. Ankr RPC ETH endpoints let you read blockchain data and submit transactions using the standard Ethereum JSON-RPC specification.
Developers use Ankr RPC ETH to connect wallets, dApps, and backend services to the Ethereum network without running their own node. The service supports both mainnet and testnets, with endpoints typically following a predictable URL pattern.
- Standard JSON-RPC over HTTPS and WebSocket
- Access to Ethereum mainnet and testnets
- Compatible with common Ethereum libraries like web3.js, ethers.js, and viem
- Authentication via API key or public endpoint depending on the plan
Ankr RPC ETH Endpoint Formats
Ankr RPC endpoints for Ethereum generally use a URL structure that includes the network name and, for authenticated access, an API key. Public endpoints may be available for limited use, but production applications typically require an API key.
The exact endpoint URL can vary based on the network (mainnet, Sepolia, etc.) and the access method (HTTPS or WebSocket). Always refer to the Ankr documentation or dashboard for the most current endpoint URLs.
- HTTPS endpoint example: https://rpc.ankr.com/eth
- WebSocket endpoint example: wss://rpc.ankr.com/eth/ws
- Authenticated endpoint example: https://rpc.ankr.com/eth/YOUR_API_KEY
- Testnet endpoints follow a similar pattern, e.g., https://rpc.ankr.com/eth_sepolia
https://rpc.ankr.com/eth
wss://rpc.ankr.com/eth/ws
https://rpc.ankr.com/eth/YOUR_API_KEYHow to Get Started with Ankr RPC ETH
To use Ankr RPC ETH, you typically need to create an account on the Ankr platform and generate an API key. The API key is used to authenticate requests and may be required for higher rate limits or advanced features.
Once you have an endpoint and API key, you can configure your Ethereum client library to send JSON-RPC requests to the Ankr URL. Most libraries accept a provider URL and handle the request formatting automatically.
- Sign up for an Ankr account (if required for your chosen access level)
- Navigate to the RPC section and select Ethereum
- Generate an API key and copy the endpoint URL
- Configure your application with the endpoint and key
- Test with a simple JSON-RPC call like eth_blockNumber
Common Ethereum JSON-RPC Methods via Ankr
Ankr RPC ETH supports the standard Ethereum JSON-RPC methods. These methods allow you to query blockchain state, send transactions, and interact with smart contracts.
Below are some frequently used methods. Note that method availability and rate limits may depend on your Ankr plan and the specific endpoint.
- eth_blockNumber: Returns the latest block number
- eth_getBalance: Returns the balance of an address
- eth_getTransactionCount: Returns the number of transactions sent from an address
- eth_sendRawTransaction: Submits a signed transaction
- eth_call: Executes a message call without creating a transaction
- eth_getLogs: Returns logs matching a filter
{
"jsonrpc": "2.0",
"method": "eth_blockNumber",
"params": [],
"id": 1
}Authentication and API Keys
Ankr RPC ETH endpoints may require an API key for authentication. The key is usually included in the URL path or as a header, depending on the endpoint format.
Public endpoints without a key may be available but often come with stricter rate limits and are not recommended for production. Always keep your API keys secure and avoid exposing them in client-side code.
- API key in URL path: https://rpc.ankr.com/eth/YOUR_API_KEY
- Some endpoints may accept the key via an Authorization header
- Store keys in environment variables or secure vaults
- Rotate keys periodically and monitor usage
Rate Limits and Pricing Considerations
Ankr offers various plans with different rate limits and features. The free tier typically includes limited requests per second or per day, while paid plans offer higher limits and additional support.
Pricing and limits are subject to change, so consult the Ankr website for current details. When designing your application, implement retry logic and error handling to gracefully handle rate limiting responses.
- Free tier available with basic limits
- Paid plans for higher throughput and advanced features
- Rate limits may vary by endpoint and method
- Use exponential backoff for retries on 429 errors
Best Practices for Using Ankr RPC ETH
To ensure reliable and efficient access to Ethereum via Ankr, follow established best practices for RPC usage. This includes monitoring performance, handling errors, and optimizing request patterns.
Consider using multiple RPC providers or fallback endpoints to increase resilience. Ankr's status page and documentation can provide updates on maintenance and incidents.
- Cache immutable data where possible to reduce requests
- Batch JSON-RPC requests if supported to improve efficiency
- Implement fallback providers for critical operations
- Monitor response times and error rates
- Stay informed about network upgrades that may affect method behavior
Troubleshooting Common Issues
When using Ankr RPC ETH, you may encounter issues such as authentication errors, rate limiting, or method not found. Understanding common error codes can help you diagnose and resolve problems quickly.
If you receive a 401 or 403 error, check your API key and endpoint URL. A 429 error indicates rate limiting, which may require upgrading your plan or optimizing request frequency.
- 401 Unauthorized: Invalid or missing API key
- 403 Forbidden: Key may not have access to the requested network
- 429 Too Many Requests: Rate limit exceeded
- Method not found: Ensure the method is supported on the network
- Timeout errors: Check network connectivity and consider increasing timeout settings