Get MATIC wallet balance
https://api.triport.io/v1/polygon/wallet/balance/0x0000000000000000000000000000000000001010?block=latestReturns the current native MATIC balance of a Polygon address, in both wei and decimal MATIC.
GET /v1/polygon/wallet/balance/{address} returns the native MATIC balance
held by a Polygon address. The balance covers native MATIC only — it does not
include ERC-20 token balances, which live in their own contracts (use
GET /v1/polygon/wallet/tokens/{address} for those).
This is one of the few endpoints available on the free tier with no
authentication. You can call it without an API key; sending a
Authorization: Bearer $TRIPORT_API_KEY header simply raises the per-second
rate limit applied to your requests.
The response gives you the balance two ways: wei as a u256 decimal string
(the exact on-chain value — always parse it with a big-integer type to avoid
precision loss) and matic as a convenience floating-point value already
divided by 10¹⁸. By default the balance is read at the latest block; pass the
block query parameter to read it at a specific height or block tag.
Parameters
Path parameters
addressstring — 0x-prefixed, 40 hex chars (^0x[0-9a-fA-F]{40}$)requiredQuery parametersobjectblockstringoptionallatest, pending, safe, finalized, or a hex/decimal block number. Defaults to latest.Response
Response fields
| Field | Type | Description |
|---|---|---|
address | string | The address that was queried (echoed back). |
wei | string | Native MATIC balance in wei as a u256 decimal string. Parse with a big-integer type; divide by 10¹⁸ for MATIC. |
matic | number (double, ≥ 0) | Convenience value: the balance already converted to MATIC. |
block | integer (int64, ≥ 0) | The block height the balance was read at. |
Errors
Errors use the shared REST envelope (error code + message, with an optional
request_id). See errors.md for the full envelope and every
shared code.
| Code | Meaning | When it happens |
|---|---|---|
401 | unauthorized · trial_expired · subscription_expired | A key was supplied but is invalid, or its trial/subscription has ended. (No key at all is still accepted on the free tier.) |
403 | tier_insufficient · method_unknown | The key's tier is below what is required, or the method is not part of your product. |
429 | rate_limited | You exceeded the sustained RPS for your tier. Honor the Retry-After header and back off. |
{
"error": "rate_limited",
"message": "Sustained RPS exceeded for category polygon_read_rpc.",
"retry_after_sec": 1,
"limit_rps": 5,
"current_tier": "free",
"category": "polygon_read_rpc"
}Examples
JavaScript (fetch)
const address = "0x0000000000000000000000000000000000001010";
const res = await fetch(
`https://api.triport.io/v1/polygon/wallet/balance/${address}`,
{
headers: {
// Optional on the free tier; required for higher rate limits.
"Authorization": `Bearer ${process.env.TRIPORT_API_KEY}`,
},
},
);
const { wei, matic, block } = await res.json();
console.log(`${matic} MATIC (${BigInt(wei)} wei) at block ${block}`);TypeScript SDK (@triport/sdk)
import { Triport } from "@triport/sdk";
const client = new Triport({ apiKey: process.env.TRIPORT_API_KEY });
const balance = await client.polygon.wallet.balance(
"0x0000000000000000000000000000000000001010",
{ block: "latest" },
);
console.log(balance.matic); // 12.45
console.log(BigInt(balance.wei)); // 12450000000000000000nPython (triport-sdk)
import os
from triport import Triport
client = Triport(api_key=os.environ.get("TRIPORT_API_KEY"))
balance = client.polygon.wallet.balance(
"0x0000000000000000000000000000000000001010",
block="latest",
)
print(balance.matic) # 12.45
print(int(balance.wei)) # 12450000000000000000Notes
- Use wei for exactness.
maticis adoubleprovided for convenience and can lose precision on large balances. For accounting, parse theweidecimal string with a big-integer type and divide by 10¹⁸ yourself. - Block selection.
pendingreflects not-yet-mined state and may change;latestis the safest default. A historical block number lets you read the balance at any past height. - Native MATIC only. For ERC-20 holdings use
/v1/polygon/wallet/tokens/{address}; for transaction history use/v1/polygon/wallet/history/{address}. - Rate limits are enforced per second per tier with up to 2× burst, and there is no daily cap. Sending an API key on this otherwise-anonymous endpoint raises your limit — see authentication and rate limits.