Token API
Token API is an Advanced API's collection of methods that comes as a unique feature along with other extensive capabilities provided to our Premium Plan users.
Token API serves to request token-related data (account balance, supported currencies, token holders, token price, etc.) across multiple EVM-compatible chains.
Token API uses only official on-chain data, leaving third parties behind. Ankr constantly scans for the on-chain transactions coming from DEXs, flagging transactions and aggregating data into accurate real-time token price feeds. This solution is crucial for the Web3 projects like marketplaces and exchanges looking for efficient ways to query accurate on-chain data for tokenized assets.
Token API implements the JSON-RPC 2.0 specification (opens in a new tab) for interaction.
Token API Methods
Token API consists of the following methods to request token-related data across multiple chains:
ankr_getAccountBalance
— retrieves the balance of a particular account.ankr_getCurrencies
— retrieves info on currencies available for a particular blockchain.ankr_getTokenPrice
— retrieves the price of a particular token.ankr_getTokenHolders
— retrieves info on holders of a particular token.ankr_getTokenHoldersCount
— retrieves the number of token holders.ankr_getTokenTransfers
— retrieves token transfers info.
Prefer interactive docs? See our OpenAPI specification (opens in a new tab) for Token API methods.
ankr_getAccountBalance
Retrieves account balance.
Retrieves the balance of the account specified.
Request
Build your request using the parameters below.
Parameters
-
id
(int64; required): a request ID (example: 1). -
jsonrpc
(string; required): a JSON RPC spec used (example: 2.0). -
method
(string; required): a method used for the request. -
params
(object): the data object containing request body parameters:blockchain
(string): a chain or a combination of chains to query:- Single chain:
arbitrum
,avalanche
,base
,bsc
,eth
,fantom
,flare
,gnosis
,linea
,optimism
,polygon
,polygon_zkevm
,rollux
,scroll
,stellar
,syscoin
,telos
,xai
,xlayer
,avalanche_fuji
,base_sepolia
,eth_holesky
,eth_sepolia
,optimism_testnet
,polygon_amoy
. - Chains combination:
[arbitrum, avalanche, base, bsc, eth, fantom, flare, gnosis, linea, optimism, polygon, polygon_zkevm, rollux, scroll, stellar, syscoin, telos, xai, xlayer, avalanche_fuji, base_sepolia, eth_holesky, eth_sepolia, optimism_testnet, polygon_amoy]
. - All chains: leave the value empty to query all the chains available.
- Single chain:
nativeFirst
(boolean): sorting order. Native network token first (true) or not (false).onlyWhitelisted
(boolean; default:true
): only show tokens listed on CoinGekko (true
) or all the tokens (false
). Default —true
.pageSize
(int32): a number of results you'd like to get (max: all; default: all).pageToken
(string): a current page token provided at the end of the response body; can be referenced in the request to fetch the next page.walletAddress
(string): an account address to query for balance; supports the Ethereum Name Service (ENS).
{
"id": 1,
"jsonrpc": "2.0",
"method": "ankr_getAccountBalance",
"params": {
"blockchain": [
"string"
],
"onlyWhitelisted": true,
"pageSize": 0,
"pageToken": "string",
"walletAddress": "string"
}
}
Response
Returns a complete set of balance data for the account specified in request body parameters.
Code Examples
Request
curl --location --request POST 'https://rpc.ankr.com/multichain' \
--header 'Content-Type: application/json' \
--data-raw '{
"jsonrpc": "2.0",
"method": "ankr_getAccountBalance",
"params": {
"blockchain": "eth",
"walletAddress": "0xfa9019df60d3c710d7d583b2d69e18d412257617"
},
"id": 1
}'
Response
Code: 200 OK
{
"error": {},
"id": 1,
"jsonrpc": "2.0",
"result": {
"assets": [
{
"balance": "string",
"balanceRawInteger": "string",
"balanceUsd": "string",
"blockchain": "string",
"contractAddress": "string",
"holderAddress": "string",
"thumbnail": "string",
"tokenDecimals": 0,
"tokenName": "string",
"tokenPrice": "string",
"tokenSymbol": "string",
"tokenType": "string"
}
],
"nextPageToken": "string",
"totalBalanceUsd": "string"
}
}
ankr_getCurrencies
Retrieves the blockchain's currencies.
Retrieves a list of all the currencies used in transactions on a blockchain specified.
Request
Build your request using the parameters below.
Parameters
-
id
(int64; required): a request ID (example: 1). -
jsonrpc
(string; required): a JSON RPC spec used (example: 2.0). -
method
(string; required): a method used for the request. -
params
(object): the data object containing request body parameters:blockchain
(string; required): either of the supported chains (arbitrum
,avalanche
,base
,bsc
,eth
,fantom
,flare
,gnosis
,linea
,optimism
,polygon
,polygon_zkevm
,rollux
,scroll
,stellar
,syscoin
,telos
,xai
,xlayer
,avalanche_fuji
,base_sepolia
,eth_holesky
,eth_sepolia
,optimism_testnet
,polygon_amoy
).
{
"id": 1,
"jsonrpc": "2.0",
"method": "ankr_getCurrencies",
"params": {
"blockchain": "string"
}
}
Response
Returns the currencies and their metadata for the blockchain specified by request body parameters.
Code Examples
Request
curl --location --request POST 'https://rpc.ankr.com/multichain' \
--header 'Content-Type: application/json' \
--data-raw '{
"jsonrpc": "2.0",
"method": "ankr_getCurrencies",
"params": {
"blockchain": "eth"
},
"id": 1
}'
Response
Code: 200 OK
{
"error": {},
"id": 1,
"jsonrpc": "2.0",
"result": {
"currencies": [
{
"address": "string",
"blockchain": "string",
"decimals": 0,
"name": "string",
"symbol": "string",
"thumbnail": "string"
}
]
}
}
ankr_getTokenPrice
Retrieves token price.
Retrieves a USD price of the token specified.
Request
Build your request using the parameters below.
Parameters
-
id
(int64; required): a request ID (example: 1). -
jsonrpc
(string; required): a JSON RPC spec used (example: 2.0). -
method
(string; required): a method used for the request. -
params
(object): the data object containing request body parameters:blockchain
(string; required): either of the supported chains (arbitrum
,avalanche
,base
,bsc
,eth
,fantom
,flare
,gnosis
,linea
,optimism
,polygon
,polygon_zkevm
,rollux
,scroll
,stellar
,syscoin
,telos
,xai
,xlayer
,avalanche_fuji
,base_sepolia
,eth_holesky
,eth_sepolia
,optimism_testnet
,polygon_amoy
).contractAddress
(string): an address of the token contract; supports the Ethereum Name Service (ENS). If not provided, returns the native coin price of the blockchain specified.
{
"id": 1,
"jsonrpc": "2.0",
"method": "ankr_getTokenPrice",
"params": {
"blockchain": "string",
"contractAddress": "string"
}
}
Response
Returns a USD price of the token specified by request body parameters.
Code Examples
Request
curl --location --request POST 'https://rpc.ankr.com/multichain' \
--header 'Content-Type: application/json' \
--data-raw '{
"jsonrpc": "2.0",
"method": "ankr_getTokenPrice",
"params": {
"blockchain": "eth",
"contractAddress": "0x8290333cef9e6d528dd5618fb97a76f268f3edd4"
},
"id": 1
}'
Response
Code: 200 OK
{
"error": {},
"id": 1,
"jsonrpc": "2.0",
"result": {
"blockchain": "string",
"contractAddress": "string",
"usdPrice": "string"
}
}
ankr_getTokenHolders
Retrieves data on token holders.
Retrieves holders (wallet addresses) and the associated metadata of the tokens specified.
Request
Build your request using the parameters below.
Parameters
-
id
(int64; required): a request ID (example: 1). -
jsonrpc
(string; required): a JSON RPC spec used (example: 2.0). -
method
(string; required): a method used for the request. -
params
(object): the data object containing request body parameters:blockchain
(string; required): either of the supported chains (arbitrum
,avalanche
,base
,bsc
,eth
,fantom
,flare
,gnosis
,linea
,optimism
,polygon
,polygon_zkevm
,rollux
,scroll
,stellar
,syscoin
,telos
,xai
,xlayer
,avalanche_fuji
,base_sepolia
,eth_holesky
,eth_sepolia
,optimism_testnet
,polygon_amoy
).contractAddress
(string): an address of the token contract; supports the Ethereum Name Service (ENS).pageSize
(int32): a number of results you'd like to get (max:10000
; default:10000
).pageToken
(string): a current page token provided at the end of the response body; can be referenced in the request to fetch the next page.
{
"id": 1,
"jsonrpc": "2.0",
"method": "ankr_getTokenHolders",
"params": {
"blockchain": "string",
"contractAddress": "string",
"pageSize": 0,
"pageToken": "string"
}
}
Response
Returns holders, holders number, and holders metadata of the tokens specified by request body parameters.
Code Examples
Request
curl --location --request POST 'https://rpc.ankr.com/multichain' \
--header 'Content-Type: application/json' \
--data-raw '{
"jsonrpc": "2.0",
"method": "ankr_getTokenHolders",
"params": {
"blockchain": "bsc",
"contractAddress": "0xf307910A4c7bbc79691fD374889b36d8531B08e3",
"pageSize": 3,
"pageToken": "4jQWQp56mXWuw2qPBV3PNcHc187va4ip31eF58pFGmXzRuz5nMM1KjV7Ykcr7fM5yJVQB8rgjp9cJXfwrX"
},
"id": 1
}'
Response
{
"error": {},
"id": 1,
"jsonrpc": "2.0",
"result": {
"blockchain": "string",
"contractAddress": "string",
"holders": [
{
"balance": "string",
"balanceRawInteger": "string",
"holderAddress": "string"
}
],
"holdersCount": 0,
"nextPageToken": "string",
"tokenDecimals": 0
}
}
ankr_getTokenHoldersCount
Retrieves the number of token holders.
Retrieves the number of holders for the tokens specified.
Request
Build your request using the parameters below.
Parameters
-
id
(int64; required): a request ID (example: 1). -
jsonrpc
(string; required): a JSON RPC spec used (example: 2.0). -
method
(string; required): a method used for the request. -
params
(object): the data object containing request body parameters:blockchain
(string; required): either of the supported chains (arbitrum
,avalanche
,base
,bsc
,eth
,fantom
,flare
,gnosis
,linea
,optimism
,polygon
,polygon_zkevm
,rollux
,scroll
,stellar
,syscoin
,telos
,xai
,xlayer
,avalanche_fuji
,base_sepolia
,eth_holesky
,eth_sepolia
,optimism_testnet
,polygon_amoy
).contractAddress
(string): an address of the token contract; supports the Ethereum Name Service (ENS).pageSize
(string): a number of results you'd like to get (max:10000
; default:10000
).pageToken
(string): a current page token provided at the end of the response body; can be referenced in the request to fetch the next page.
{
"id": 1,
"jsonrpc": "2.0",
"method": "ankr_getTokenHoldersCount",
"params": {
"blockchain": "string",
"contractAddress": "string",
"pageSize": 0,
"pageToken": "string"
}
}
Response
Returns the number of holders for the tokens specified by request body parameters.
Code Examples
Request
curl --location --request POST 'https://rpc.ankr.com/multichain' \
--header 'Content-Type: application/json' \
--data-raw '{
"jsonrpc": "2.0",
"method": "ankr_getTokenHoldersCount",
"params": {
"blockchain": "eth",
"contractAddress": "0xdAC17F958D2ee523a2206206994597C13D831ec7",
"pageSize": 10,
"pageToken": ""
},
"id": 1
}'
Response
{
"error": {},
"id": 1,
"jsonrpc": "2.0",
"result": {
"blockchain": "string",
"contractAddress": "string",
"holderCountHistory": [
{
"holderCount": 0,
"lastUpdatedAt": "string",
"totalAmount": "string",
"totalAmountRawInteger": "string"
}
],
"nextPageToken": "string",
"tokenDecimals": 0
}
}
ankr_getTokenTransfers
Retrieves info on token transfers for the wallet address specified.
Request
Build your request using the parameters below.
Parameters
-
id
(int64; required): a request ID (example: 1). -
jsonrpc
(string; required): a JSON RPC spec used (example: 2.0). -
method
(string; required): a method used for the request. -
params
(object): the data object containing request body parameters:address
(array of strings; required): an address or a list of addresses to search for token transfers.blockchain
(string): a chain or a combination of chains to query:- Single chain:
arbitrum
,avalanche
,base
,bsc
,eth
,fantom
,flare
,gnosis
,linea
,optimism
,polygon
,polygon_zkevm
,rollux
,scroll
,stellar
,syscoin
,telos
,xai
,xlayer
,avalanche_fuji
,base_sepolia
,eth_holesky
,eth_sepolia
,optimism_testnet
,polygon_amoy
. - Chains combination:
[arbitrum, avalanche, base, bsc, eth, fantom, flare, gnosis, linea, optimism, polygon, polygon_zkevm, rollux, scroll, stellar, syscoin, telos, xai, xlayer, avalanche_fuji, base_sepolia, eth_holesky, eth_sepolia, optimism_testnet, polygon_amoy]
. - All chains: leave the value empty to query all the chains available.
- Single chain:
descOrder
(boolean): choose data order, either descending (iftrue
) or ascending (iffalse
).fromBlock
(integer): narrow your search indicating the block number to start from (inclusive;>= 0
). Supported value formats: hex, decimal, "earliest", "latest".toBlock
(integer): narrow your search indicating the block number to end with (inclusive;>= 0
). Supported value formats: hex, decimal, "earliest", "latest".fromTimestamp
(integer): narrow your search indicating the UNIX timestamp to start from (inclusive;>= 0
).toTimestamp
(integer): narrow your search indicating the UNIX timestamp to end with (inclusive;>=0
).pageSize
(integer): a number of result pages you'd like to get (max:10000
; default:10000
).pageToken
(string): a current page token provided in the response; can be referenced in the request to fetch the next page.
{
"id": 1,
"jsonrpc": "2.0",
"method": "ankr_getTokenTransfers",
"params": {
"address": "string",
"blockchain": [
"string",
"string"
],
"fromTimestamp": 0,
"toTimestamp": 0
}
}
Response
Returns info on transfers of the tokens specified by request body parameters.
Code Examples
Request
curl --location --request POST 'https://rpc.ankr.com/multichain' \
--header 'Content-Type: application/json' \
--data-raw '{
"jsonrpc": "2.0",
"method": "ankr_getTokenTransfers",
"params": {
"address": "0xd8da6bf26964af9d7eed9e03e53415d37aa96045",
"blockchain": [
"eth",
"bsc"
],
"fromTimestamp": 1655197483,
"toTimestamp": 1671974699
},
"id": 1
}'
Response
Code: 200 OK
{
"id": 1,
"jsonrpc": "2.0",
"result": {
"transfers": [
{
"blockHeight": 4593859,
"blockchain": "eth",
"contractAddress": "0xdd974d5c2e2928dea5f71b9825b8b646686bd200",
"fromAddress": "0xd8da6bf26964af9d7eed9e03e53415d37aa96045",
"thumbnail": "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ethereum/assets/0xdd974D5C2e2928deA5F71b9825b8b646686BD200/logo.png",
"timestamp": 1511258315,
"toAddress": "0x0cfb686e114d478b055ce8614621f8bb62f70360",
"tokenDecimals": 18,
"tokenName": "Kyber Network Crystal",
"tokenSymbol": "KNC",
"transactionHash": "0xfc2192e9716490dbe46c3d59c7c99f81d3b685118b01e2812872a6aae7049c4b",
"value": "3420332",
"valueRawInteger": ""
},
{
"blockHeight": 10762240,
"blockchain": "bsc",
"contractAddress": "0xc33fc11b55465045b3f1684bde4c0aa5c5f40124",
"fromAddress": "0xc33fc11b55465045b3f1684bde4c0aa5c5f40124",
"thumbnail": "",
"timestamp": 1631185820,
"toAddress": "0xd8da6bf26964af9d7eed9e03e53415d37aa96045",
"tokenDecimals": 9,
"tokenName": "BNBw.io",
"tokenSymbol": "BNBw",
"transactionHash": "0x74aa1d7c858bd8d9bb1daf5311ec5f6cdb16df165e6f242127f6502775993570",
"value": "21131181",
"valueRawInteger": ""
}
]
}
}