π° How to Easily Check Multi-Chain Crypto Wallet Balances with Multichain Crypto API
Crypto developers often face challenges when checking wallet balances or transaction statuses across multiple blockchains. Doing it manually can be tedious, especially if you need to support Solana, Ethereum, BSC, Polygon, TRON, or Base at the same time.
Fortunately, the Multichain Crypto API π allows developers to directly query blockchain data via ready-to-use API endpoints, without running nodes themselves.
π οΈ Setup
- Python 3.11+
- Install dependencies:
pip install httpx asyncio
- RapidAPI key (sign up and subscribe to Multichain Crypto API)
β‘ Python Async Example
Create a file called check_balance.py:
import asyncio
import httpx
import logging
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)
API_URL = "https://multichain-crypto-api4.p.rapidapi.com/api/v1/crypto/balance"
API_KEY = "YOUR_RAPIDAPI_KEY"
async def get_balance(chain: str, wallet: str):
async with httpx.AsyncClient() as client:
try:
resp = await client.get(
API_URL,
params={"chain": chain, "wallet": wallet},
headers={"X-RapidAPI-Key": API_KEY}
)
resp.raise_for_status()
data = resp.json()
logger.info(f"Balance data: {data}")
return data
except httpx.HTTPError as e:
logger.error(f"Failed to fetch data: {e}")
return None
async def main():
chain = "sol"
wallet = "BnwKsYcEYMCZBTdgTQ8NE3QT79Yj"
balance_data = await get_balance(chain, wallet)
if balance_data:
print(f"Wallet: {balance_data['wallet']}")
print(f"Chain: {balance_data['chain']}")
print(f"Balance: {balance_data['balance']}")
if __name__ == "__main__":
asyncio.run(main())
π₯οΈ CURL Example
Quick test without Python:
curl "https://multichain-crypto-api4.p.rapidapi.com/api/v1/crypto/balance?rpc_url=https://api.devnet.solana.com&chain=sol&wallet=BnwKsYcEYMCZBTdgTQ8NE3QT79YjzzBdjevPQFKvd4B5" \
-H "X-RapidAPI-Key: YOUR_RAPIDAPI_KEY" \
-H "X-RapidAPI-Host: multichain-crypto-api4.p.rapidapi.com"
Notes:
- Replace
YOUR_RAPIDAPI_KEYwith your key - Use testnet wallet for safety
π Sample Output
{
"status": "ok",
"chain": "sol",
"wallet": "BnwKsYcEYMCZBTdgTQ8NE3QT79Yj",
"balance": 12.345
}
Console output:
Wallet: BnwKsYcEYMCZBTdgTQ8NE3QT79Yj
Chain: sol
Balance: 12.345
βΆοΈ How to Run
- Save the script as
check_balance.py - Replace
YOUR_RAPIDAPI_KEYwith your RapidAPI key - Run:
python check_balance.py
- See the wallet balance printed on the console
π Explore More Endpoints
Check out the Multichain Crypto API on RapidAPI for more endpoints and integrations.
π‘ Pro Tip: Combine this API with webhooks or alert systems for real-time balance notifications β perfect for traders or devs needing instant data.
Top comments (0)