← Protocols
Ankr RPC
RPC / Node·EVM · Solana · Cosmos · Multi-chain

Ankr RPC

01Description

Multi-chain RPC service plus Advanced (NFT, Token, Query) and Token-as-a-Service APIs across 80+ networks, with HTTPS and WSS endpoints and debug/trace on Premium.

02Best for
  • 01broad multi-chain RPC coverage
  • 02Advanced APIs (NFT, Token, Query)
  • 03WSS subscriptions
  • 04debug/trace on EVM (Premium)
  • 05token gating with ANKR holdings
03Install
  • pnpm add @ankr.com/ankr.js viem
04Environment variables
VariableScopeDescription
ANKR_API_KEYServerAnkr Premium project token (the path segment appended to the chain endpoint). Server-side only.
ANKR_RPC_URLServerFull Ankr Premium RPC URL, e.g. `https://rpc.ankr.com/eth/<ANKR_API_KEY>` for Ethereum mainnet. Server-side only.
05Prompt snippet
Use Ankr Premium RPC as the JSON-RPC transport. Endpoint URL pattern: `https://rpc.ankr.com/<chain>/<ANKR_API_KEY>` (e.g. `eth`, `base`, `arbitrum`, `polygon`, `avalanche`, `bsc`, `solana`, `optimism`). Wire into `viem` via `createPublicClient({ chain: mainnet, transport: http(process.env.ANKR_RPC_URL) })`. WSS is the same path on `wss://rpc.ankr.com/<chain>/<key>`. For NFT, Token, and Query data, use `@ankr.com/ankr.js` against `https://rpc.ankr.com/multichain/<key>` — methods like `ankr_getNFTsByOwner`, `ankr_getAccountBalance`, and `ankr_getLogs` query across multiple EVM chains in one call. Debug/trace methods (`debug_traceTransaction`, `trace_block`) are Premium-only on EVM. Note: this is distinct from `ankr-staking` (liquid staking).
06Gotchas
  • Ankr's URL embeds the project token in the path — leaking it grants full Premium quota to attackers. Never expose it client-side; proxy via a server route.
  • The Public plan (no key) is rate-limited per IP, lacks WSS on most chains, and has no debug/trace — production must use Premium.
  • Free Premium tier has a monthly request cap; archive-state requests and debug/trace count the same as `eth_blockNumber`, so historical scrapes burn the quota fast.
  • Multichain Advanced API endpoints (`ankr_getNFTsByOwner`, etc.) live on the `multichain` path, NOT on the per-chain RPC endpoint — calling them on `rpc.ankr.com/eth/<key>` returns method-not-found.
  • Regional latency varies — Ankr does not pin endpoints to a region the way QuickNode does; for low-latency p99 in EU/APAC, benchmark against alternatives or use a dedicated node.
  • Eviction policy on shared nodes: very large `eth_getLogs` ranges (>10k blocks) routinely 413/timeout — paginate by block range or use the Query API instead.
  • Distinct integration from `ankr-staking` (ankrETH/ankrBNB liquid staking) — keep keys and addresses scoped per integration.
07Alternatives