Get Token Balances for a User or Token
curl --request GET \
--url https://api.gm.ondo.finance/v1/chains/{chainId}/balances \
--header 'x-api-key: <api-key>'import requests
url = "https://api.gm.ondo.finance/v1/chains/{chainId}/balances"
headers = {"x-api-key": "<api-key>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {'x-api-key': '<api-key>'}};
fetch('https://api.gm.ondo.finance/v1/chains/{chainId}/balances', 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.gm.ondo.finance/v1/chains/{chainId}/balances",
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: <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.gm.ondo.finance/v1/chains/{chainId}/balances"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("x-api-key", "<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.gm.ondo.finance/v1/chains/{chainId}/balances")
.header("x-api-key", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.gm.ondo.finance/v1/chains/{chainId}/balances")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["x-api-key"] = '<api-key>'
response = http.request(request)
puts response.read_body{
"tokens": [
{
"tokenAddress": "0x14c3abf95cb9c93a8b82c1cdcb76d72cb87b2d4c",
"tokenSymbol": "AAPLon",
"balances": [
{
"holderAddress": {
"account": "0x13116e8b4ffc8125b859ec60917fba540e59e55e"
},
"balance": "0.467583800117038432"
},
{
"holderAddress": {
"account": "0x1db995cb2b3d9679383f0e597704a41e1521f4e1"
},
"balance": "0.641380199330235549"
}
]
},
{
"tokenAddress": "0xf6b1117ec07684d3958cad8beb1b302bfd21103f",
"tokenSymbol": "TSLAon",
"balances": [
{
"holderAddress": {
"account": "0x00000688768803bbd44095770895ad27ad6b0d95"
},
"balance": "0.030594824589372964"
},
{
"holderAddress": {
"account": "0x1db995cb2b3d9679383f0e597704a41e1521f4e1"
},
"balance": "0.088854297224463519"
}
]
},
"..."
]
}{
"code": "INVALID_SYMBOL",
"message": "One of the request parameters is invalid.",
"documentation": "https://docs.ondo.finance/api-reference/error-codes#invalid_symbol"
}{
"code": "MISSING_API_KEY",
"message": "missing API key",
"documentation": "https://docs.ondo.finance/api-reference/error-codes#missing_api_key"
}{
"code": "RATE_LIMITED",
"message": "rate limit exceeded",
"documentation": "https://docs.ondo.finance/api-reference/error-codes#rate_limited"
}{
"code": "INTERNAL_ERROR",
"message": "An internal server error occurred. Please see the returned message and documentation for details.",
"documentation": "https://docs.ondo.finance/api-reference/error-codes#internal_error"
}Chains
Get Token Balances for a User or Token
This endpoint retrieves all token balances for a GM Chain. Results can be optionally filtered by tokenAddress, userAddress, or both parameters together. If no filters are provided, all balances on the chain will be returned.
For caching details on this endpoint, please see: Endpoint Caching.
GET
/
v1
/
chains
/
{chainId}
/
balances
Get Token Balances for a User or Token
curl --request GET \
--url https://api.gm.ondo.finance/v1/chains/{chainId}/balances \
--header 'x-api-key: <api-key>'import requests
url = "https://api.gm.ondo.finance/v1/chains/{chainId}/balances"
headers = {"x-api-key": "<api-key>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {'x-api-key': '<api-key>'}};
fetch('https://api.gm.ondo.finance/v1/chains/{chainId}/balances', 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.gm.ondo.finance/v1/chains/{chainId}/balances",
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: <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.gm.ondo.finance/v1/chains/{chainId}/balances"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("x-api-key", "<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.gm.ondo.finance/v1/chains/{chainId}/balances")
.header("x-api-key", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.gm.ondo.finance/v1/chains/{chainId}/balances")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["x-api-key"] = '<api-key>'
response = http.request(request)
puts response.read_body{
"tokens": [
{
"tokenAddress": "0x14c3abf95cb9c93a8b82c1cdcb76d72cb87b2d4c",
"tokenSymbol": "AAPLon",
"balances": [
{
"holderAddress": {
"account": "0x13116e8b4ffc8125b859ec60917fba540e59e55e"
},
"balance": "0.467583800117038432"
},
{
"holderAddress": {
"account": "0x1db995cb2b3d9679383f0e597704a41e1521f4e1"
},
"balance": "0.641380199330235549"
}
]
},
{
"tokenAddress": "0xf6b1117ec07684d3958cad8beb1b302bfd21103f",
"tokenSymbol": "TSLAon",
"balances": [
{
"holderAddress": {
"account": "0x00000688768803bbd44095770895ad27ad6b0d95"
},
"balance": "0.030594824589372964"
},
{
"holderAddress": {
"account": "0x1db995cb2b3d9679383f0e597704a41e1521f4e1"
},
"balance": "0.088854297224463519"
}
]
},
"..."
]
}{
"code": "INVALID_SYMBOL",
"message": "One of the request parameters is invalid.",
"documentation": "https://docs.ondo.finance/api-reference/error-codes#invalid_symbol"
}{
"code": "MISSING_API_KEY",
"message": "missing API key",
"documentation": "https://docs.ondo.finance/api-reference/error-codes#missing_api_key"
}{
"code": "RATE_LIMITED",
"message": "rate limit exceeded",
"documentation": "https://docs.ondo.finance/api-reference/error-codes#rate_limited"
}{
"code": "INTERNAL_ERROR",
"message": "An internal server error occurred. Please see the returned message and documentation for details.",
"documentation": "https://docs.ondo.finance/api-reference/error-codes#internal_error"
}
