Wallet balances: wallet.balances¶
Reads on-chain token balances (for example outcome tokens) of a wallet.
| HTTP | GET https://future.news/td/api/v1/wallet/balances |
| Auth | required: FutureNews(auth_token=...), see Authentication |
| Returns | ApiResponse |
Parameters¶
| Parameter | Type | Default | Notes |
|---|---|---|---|
wallet_address |
str |
required | 0x... address. Non-empty. |
chain |
str |
"polygon" |
|
token_addresses |
Iterable[str] |
() |
repeated query parameter, one per address |
token_ids |
Iterable[str] |
() |
repeated query parameter, one per id. Pass them as strings (or ints). Don't round-trip them through floats or JSON numbers first, which loses digits. |
Without auth_token the call raises AuthRequiredError before any request is sent.
Example (sync)¶
import os
from futurenews import FutureNews
with FutureNews(auth_token=os.environ["FUTURENEWS_TOKEN"]) as client:
balances = client.wallet.balances(
"0xYourWalletAddress",
token_addresses=["0xTokenContract"],
token_ids=["1234567890", "9876543210"],
)
print(balances.data)
Example (async)¶
import asyncio, os
from futurenews import AsyncFutureNews
async def main():
async with AsyncFutureNews(auth_token=os.environ["FUTURENEWS_TOKEN"]) as client:
print((await client.wallet.balances("0xYourWalletAddress")).data)
asyncio.run(main())
Keep your token secret
Read it from an environment variable, never hard-code or commit it. Access tokens expire after roughly 30 minutes; an expired token raises AuthenticationError.
Equivalent request¶
curl 'https://future.news/td/api/v1/wallet/balances?chain=polygon&wallet_address=0x...&token_addresses=0x...&token_ids=1&token_ids=2' \
-H 'authorization: Bearer <token>'
About the response
Future News does not publish a schema. The library returns the payload as an ApiResponse: .data holds the "data" field (or the whole JSON when there is none) and .raw always holds the untouched JSON. Unknown fields are never dropped. Field-level models are added once sample responses are confirmed, so treat the shape as subject to change.
Related: Authentication · Errors & Cloudflare · All endpoints
Don't have a Future News account?
Sign up with our link. It's free for you and supports this library.
Build something with this data
Chipa dev team builds trading bots and tools: Bot development · ChipaX exchange · Chipa Editor · Discord