getTokenSupply
https://api.triport.io/v1/solReturns the total circulating supply of an SPL token mint.
getTokenSupply returns the total supply currently in circulation for a single
SPL token mint. The amount is reported both as a raw integer string (in the
token's smallest indivisible unit) and as a human-readable value scaled by the
mint's decimals.
Use it to display a token's circulating supply, to compute market cap alongside
a price feed, or to confirm a mint's decimal precision before formatting other
balances. The value reflects the supply as recorded on-chain at the slot named
in the response context — pass a stricter commitment (e.g. finalized) when
you need a confirmed, rollback-safe number.
This is a lightweight read; it is rate limited under the standard
sol_read_rpc bucket and is available on every tier including free.
Parameters
Positional params array: [mint, config?].
mintstring (Pubkey, base-58)requiredconfigobjectoptionalcommitmentstringoptionalprocessed, confirmed, or finalized. Defaults to the node default if omitted.Response
The example above queries the USDC mint and returns a total supply of
4827361029847562 base units, i.e. 4827361029.847562 USDC at 6 decimals.
resultobjectTokenBalanceResponse envelope.result.contextobjectresult.context.slotintegerresult.context.apiVersionstringresult.value.amountstringresult.value.decimalsintegerresult.value.uiAmountnumber | nulldecimals as a JSON number. May be null if the value is not safely representable.result.value.uiAmountStringstringdecimals as a string — prefer this for display to avoid floating-point loss.Errors
Errors are returned in the standard JSON-RPC error envelope. See the shared errors reference for the full envelope shape and shared codes.
| Code | Meaning | When it happens |
|---|---|---|
-32602 | Invalid params | mint is missing, malformed, or not a valid base-58 Pubkey, or the account is not an SPL Token mint. |
401 | Unauthorized | Missing or invalid Authorization bearer token. |
403 | Forbidden | The API key lacks the sol_read_rpc scope. |
429 | Rate limited | More than your tier's RPS for sol_read_rpc (20 / 60 / 200 / 600). |
Examples
JavaScript (fetch)
const res = await fetch("https://api.triport.io/v1/sol", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.TRIPORT_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
jsonrpc: "2.0",
id: 1,
method: "getTokenSupply",
params: ["EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v", { commitment: "finalized" }],
}),
});
const { result } = await res.json();
console.log(result.value.uiAmountString);TypeScript SDK (@triport/sdk)
import { TriportClient } from "@triport/sdk";
const client = new TriportClient({ apiKey: process.env.TRIPORT_API_KEY });
const supply = await client.solana.getTokenSupply(
"EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
{ commitment: "finalized" }
);
console.log(supply.value.uiAmountString, "decimals:", supply.value.decimals);Python (triport-sdk)
import os
from triport import TriportClient
client = TriportClient(api_key=os.environ["TRIPORT_API_KEY"])
supply = client.solana.get_token_supply(
"EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
commitment="finalized",
)
print(supply["value"]["uiAmountString"], "decimals:", supply["value"]["decimals"])Notes
- For display and arithmetic, prefer
value.uiAmountStringovervalue.uiAmount: the string form preserves precision, while the numeric form can benullor lossy for very large supplies. value.amountis denominated in the smallest unit; divide by10 ** decimalsto get the human-readable supply (which is exactly whatuiAmountStringalready gives you).- To read a single holder's balance instead of the whole supply, use getTokenAccountBalance. For the largest holders of a mint, see getTokenLargestAccounts.
- A stale or unexpected supply is often a
commitmentissue — requestfinalizedfor a confirmed, rollback-safe number.