suix_getAllBalances{deprecated} - Sui

This method retrieves all coin balances for every token type owned by an address on the SUI network, returning aggregated balance information for each coin type in a single response.

This method is deprecated

Parameters

ParameterTypeRequiredDescriptionDefault/Supported Values
ownerstringYesThe owner's SUI address to query all balances forMust be a valid SUI address starting with "0x"

Request Example

bashcurl --location --request POST https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/ \
--header 'Content-Type: application/json' \
--data-raw '{
  "jsonrpc": "2.0",
  "method": "suix_getAllBalances",
  "params": [
    "0x94f1a597b4e8f709a396f7f6b1482bdcd65a673d111e49286c527fab7c2d0961"
  ],
  "id": "getblock.io"
}'

suix_getAllBalances.py

pythonimport requests
import json

url = "https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/"
headers = {"Content-Type": "application/json"}

payload = {
    "jsonrpc": "2.0",
    "method": "suix_getAllBalances",
    "params": [
        "0x94f1a597b4e8f709a396f7f6b1482bdcd65a673d111e49286c527fab7c2d0961"
    ],
    "id": "getblock.io"
}

response = requests.post(url, headers=headers, data=json.dumps(payload))

if response.status_code == 200:
    print("Result:", response.json().get("result"))
else:
    print("Error:", response.status_code, response.text)

suix_getAllBalances.js

javascriptconst axios = require('axios');

const url = "https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/";
const payload = {
  jsonrpc: "2.0",
  method: "suix_getAllBalances",
  params: [
    "0x94f1a597b4e8f709a396f7f6b1482bdcd65a673d111e49286c527fab7c2d0961"
  ],
  id: "getblock.io"
};

axios.post(url, payload, {
  headers: { "Content-Type": "application/json" }
})
.then(response => {
  console.log("Result:", response.data.result);
})
.catch(error => {
  console.error("Error:", error.response?.status, error.response?.data);
});

suix_getAllBalances.rs

rustuse reqwest::Client;
use serde_json::json;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let client = Client::new();
    
    let payload = json!({
        "jsonrpc": "2.0",
        "id": "getblock.io",
        "method": "suix_getAllBalances",
        "params": [
            "0x94f1a597b4e8f709a396f7f6b1482bdcd65a673d111e49286c527fab7c2d0961"
        ]
    });

    let response = client
        .post("https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/")
        .header("Content-Type", "application/json")
        .json(&payload)
        .send()
        .await?;

    println!("Response: {:?}", response.text().await?);
    Ok(())
}

Sample Response

json{
  "jsonrpc": "2.0",
  "id": "getblock.io",
  "result": [
    {
      "coinType": "0x2::sui::SUI",
      "coinObjectCount": 15,
      "totalBalance": "3000000000",
      "lockedBalance": {}
    },
    {
      "coinType": "0x168da5bf1f48dafc111b0a488fa454aca95e0b5e::usdc::USDC",
      "coinObjectCount": 3,
      "totalBalance": "1500000000",
      "lockedBalance": {}
    }
  ]
}

Response Parameters

ParameterTypeDescription
jsonrpcstringThe JSON-RPC protocol version ("2.0")
idstringRequest identifier matching the request
resultarrayArray of balance objects for each coin type
result[].coinTypestringThe fully qualified coin type identifier
result[].coinObjectCountintegerNumber of coin objects for this type
result[].totalBalancestringTotal balance in the coin's smallest unit
result[].lockedBalanceobjectMap of locked balance amounts

Use Cases

  1. Portfolio Display: Display complete token holdings in wallet applications by fetching all balances in a single call, enabling comprehensive portfolio views without multiple API requests.
  2. Multi-Token Analytics: Build analytics dashboards that track holdings across all token types, calculating total portfolio value by aggregating balances and market prices.
  3. Account Overview: Provide users with a complete overview of their SUI account holdings, including native SUI and all custom tokens they own.

Error handling

CodeDescriptionSolution
Invalid Address FormatThe SUI address is not properly formattedEnsure the address is a valid 66-character hexadecimal string starting with '0x'
Empty ResultAddress has no coin objectsVerify the address has received tokens
Network ErrorConnection issues with the RPC endpointCheck network connectivity and endpoint availability

SDK Integration

TypeScript

typescriptimport { SuiClient } from '@mysten/sui/client';

const client = new SuiClient({ url: 'https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/' });

const balances = await client.getAllBalances({
  owner: '0x94f1a597b4e8f709a396f7f6b1482bdcd65a673d111e49286c527fab7c2d0961',
});

console.log(balances);

Rust (SDK)

rustuse sui_sdk::SuiClientBuilder;

#[tokio::main]
async fn main() -> Result<(), anyhow::Error> {
    let sui = SuiClientBuilder::default()
        .build("https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/")
        .await?;
    
    let address = "0x94f1a597b4e8f709a396f7f6b1482bdcd65a673d111e49286c527fab7c2d0961".parse()?;
    let balances = sui.coin_read_api().get_all_balances(address).await?;
    
    println!("{:?}", balances);
    Ok(())
}