07.5 · API
Portal balance route
The local helper this site uses to format a balance. It is not a 0G protocol API.
GET /api/balance proxies three RPC calls so the browser does not depend on the RPC allowing CORS. It returns JSON. It cannot move tokens.
01
/api/balance
GETRead chain id, balance, and block height for one address.
Request
GET /api/balance?network=galileo&address=0xYOUR_ADDRESS
network: galileo | mainnetResponse
{
"network": "galileo",
"expectedChainId": 16602,
"chainId": 16602,
"chainMatch": true,
"balanceWei": "100000000000000000",
"balance": "0.1",
"symbol": "0G",
"blockNumber": 1111111,
"explorer": "https://chainscan-galileo.0g.ai/address/0xYOUR_ADDRESS"
}- 400 when the address is not 0x plus 40 hex characters, or the network id is unknown.
- 502 when the RPC cannot be reached or returns an error. The message is the RPC’s message when it sent one.