Get ERC20 token balances
curl --request GET \
--url https://api.chainbase.online/v1/account/tokens \
--header 'x-api-key: <x-api-key>'import requests
url = "https://api.chainbase.online/v1/account/tokens"
headers = {"x-api-key": "<x-api-key>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {'x-api-key': '<x-api-key>'}};
fetch('https://api.chainbase.online/v1/account/tokens', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.chainbase.online/v1/account/tokens",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"x-api-key: <x-api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.chainbase.online/v1/account/tokens"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("x-api-key", "<x-api-key>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.chainbase.online/v1/account/tokens")
.header("x-api-key", "<x-api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.chainbase.online/v1/account/tokens")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["x-api-key"] = '<x-api-key>'
response = http.request(request)
puts response.read_body{
"code": 0,
"message": "ok",
"data": [
{
"contract_address": "<string>",
"decimals": 123,
"name": "<string>",
"symbol": "<string>",
"balance": "<string>",
"total_supply": "<string>",
"logos": [
{
"uri": "<string>",
"width": 123,
"height": 123
}
],
"urls": [
{
"name": "<string>",
"url": "<string>"
}
],
"current_usd_price": 123
}
],
"next_page": 123,
"count": 123
}{
"code": 123,
"message": "<string>"
}{
"code": 123,
"message": "<string>"
}{
"code": 123,
"message": "<string>"
}{
"code": 123,
"message": "<string>"
}{
"code": 123,
"message": "<string>"
}{
"code": 123,
"message": "<string>"
}Balance API
Get ERC20 token balances
Retrieve all token balances for all ERC20 tokens for a specified address.
By default, it will return all token balances for all ERC20 tokens that the address has ever received. You can specify a contract address to check the balance of a non-standard contract.
GET
/
v1
/
account
/
tokens
Get ERC20 token balances
curl --request GET \
--url https://api.chainbase.online/v1/account/tokens \
--header 'x-api-key: <x-api-key>'import requests
url = "https://api.chainbase.online/v1/account/tokens"
headers = {"x-api-key": "<x-api-key>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {'x-api-key': '<x-api-key>'}};
fetch('https://api.chainbase.online/v1/account/tokens', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.chainbase.online/v1/account/tokens",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"x-api-key: <x-api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.chainbase.online/v1/account/tokens"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("x-api-key", "<x-api-key>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.chainbase.online/v1/account/tokens")
.header("x-api-key", "<x-api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.chainbase.online/v1/account/tokens")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["x-api-key"] = '<x-api-key>'
response = http.request(request)
puts response.read_body{
"code": 0,
"message": "ok",
"data": [
{
"contract_address": "<string>",
"decimals": 123,
"name": "<string>",
"symbol": "<string>",
"balance": "<string>",
"total_supply": "<string>",
"logos": [
{
"uri": "<string>",
"width": 123,
"height": 123
}
],
"urls": [
{
"name": "<string>",
"url": "<string>"
}
],
"current_usd_price": 123
}
],
"next_page": 123,
"count": 123
}{
"code": 123,
"message": "<string>"
}{
"code": 123,
"message": "<string>"
}{
"code": 123,
"message": "<string>"
}{
"code": 123,
"message": "<string>"
}{
"code": 123,
"message": "<string>"
}{
"code": 123,
"message": "<string>"
}Headers
Example:
"demo"
Query Parameters
chain network id, see list of details
A hex string referencing a wallet address
Pattern:
^0[xX]{1}[a-fA-F0-9]{40}$The address of the token contract, or filter multiple addresses, (max 100), eg:contract_address=0xdac17f958d2ee523a2206206994597c13d831ec7,0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48
Pattern:
^0[xX]{1}[a-fA-F0-9]{40}$The desired page size limit. Less or equal than 100
Required range:
1 <= x <= 100The page offset
Required range:
x >= 1