Ankr API integration

We design and develop full-cycle blockchain solutions: from smart contract architecture to launching DeFi protocols, NFT marketplaces and crypto exchanges. Security audits, tokenomics, integration with existing infrastructure.
Showing 1 of 1 servicesAll 1306 services
Ankr API integration
Simple
~1 business day
FAQ
Blockchain Development Services
Blockchain Development Stages
Latest works
  • image_website-b2b-advance_0.png
    B2B ADVANCE company website development
    1217
  • image_web-applications_feedme_466_0.webp
    Development of a web application for FEEDME
    1161
  • image_websites_belfingroup_462_0.webp
    Website development for BELFINGROUP
    852
  • image_ecommerce_furnoro_435_0.webp
    Development of an online store for the company FURNORO
    1046
  • image_logo-advance_0.png
    B2B Advance company logo design
    561
  • image_crm_enviok_479_0.webp
    Development of a web application for Enviok
    823

Ankr API Integration

Most Web3 projects start with public RPC endpoints — and quickly hit rate limits, instability, and lack of archive data. Ankr solves several problems at once: it's a multi-chain RPC provider supporting 50+ networks, with archive nodes and a set of specialized APIs on top of raw RPC calls.

What exactly Ankr provides

Premium RPC — standard JSON-RPC endpoints for EVM and non-EVM networks. Compared to public endpoints: guaranteed rate limits, SLA uptime, support for archive methods (eth_getBalance on any historical block).

Ankr Advanced API — high-level methods not available in standard JSON-RPC:

  • ankr_getAccountBalance — multi-chain account balance across all tokens at once
  • ankr_getNFTsByOwner — all owner NFTs across all networks
  • ankr_getTransactionsByAddress — transaction history with pagination
  • ankr_getTokenHolders — token holders

Without these methods, the same result requires dozens of RPC calls and custom indexing.

Integration practice

Ankr is compatible with standard Web3 libraries — just replace the RPC URL:

import { createPublicClient, http } from "viem";
import { mainnet, polygon, bsc } from "viem/chains";

const ankrKey = process.env.ANKR_API_KEY;

const ethClient = createPublicClient({
  chain: mainnet,
  transport: http(`https://rpc.ankr.com/eth/${ankrKey}`),
});

// Advanced API via separate SDK
import AnkrProvider from "@ankr.com/ankr.js";
const ankr = new AnkrProvider(`https://rpc.ankr.com/multichain/${ankrKey}`);

// Get all token balances for address across all networks in one request
const { assets } = await ankr.getAccountBalance({
  walletAddress: "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045",
  blockchain: ["eth", "polygon", "bsc", "arbitrum"],
});

Error handling and retry

Ankr returns standard JSON-RPC errors plus specific codes. Mandatory pattern:

async function withRetry<T>(
  fn: () => Promise<T>,
  maxAttempts = 3,
  baseDelayMs = 500
): Promise<T> {
  for (let attempt = 0; attempt < maxAttempts; attempt++) {
    try {
      return await fn();
    } catch (err: any) {
      const isRateLimit = err?.code === 429 || err?.message?.includes("rate limit");
      const isRetryable = isRateLimit || err?.code === -32603; // internal error
      if (!isRetryable || attempt === maxAttempts - 1) throw err;
      await delay(baseDelayMs * 2 ** attempt); // exponential backoff
    }
  }
  throw new Error("unreachable");
}

Multi-chain balances in production

Advanced API is especially useful for portfolio trackers and wallets. Without it "show all user tokens" requires: iterate through all networks, all potentially relevant tokens, make balanceOf calls — hundreds of requests. With ankr_getAccountBalance — one request, response includes USD prices.

Limitations to know

Rate limits depend on plan. Free tier: 30 req/s. Premium: 1500+ req/s. At high load — combine Ankr with own nodes or other providers.

Advanced API doesn't cover all networks. Standard RPC exists for 50+ networks, Advanced API — for ~20 major ones. Before project planning — check current list in documentation.

Advanced API data is not real-time. Ankr's indexer updates with small delay (~30–60 sec). For critical financial data on latest block — use direct RPC, not Advanced API.

When to choose Ankr

Ankr is justified if: you need quick start with multi-chain support, you need archive data without own node, you need high-level methods (balances, NFTs, transaction history) without writing custom indexer. At load > 1M requests/day — calculate economics: own node pays for itself faster than it seems.