DEV Community

Zaenal Arifin
Zaenal Arifin

Posted on • Edited on

πŸ’° How to Easily Check Multi-Chain Crypto Wallet Balances with Multichain Crypto API

πŸ’° 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
Enter fullscreen mode Exit fullscreen mode

⚑ 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())
Enter fullscreen mode Exit fullscreen mode

πŸ–₯️ 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"
Enter fullscreen mode Exit fullscreen mode

Notes:

  • Replace YOUR_RAPIDAPI_KEY with your key
  • Use testnet wallet for safety

πŸ“Š Sample Output

{
  "status": "ok",
  "chain": "sol",
  "wallet": "BnwKsYcEYMCZBTdgTQ8NE3QT79Yj",
  "balance": 12.345
}
Enter fullscreen mode Exit fullscreen mode

Console output:

Wallet: BnwKsYcEYMCZBTdgTQ8NE3QT79Yj
Chain: sol
Balance: 12.345
Enter fullscreen mode Exit fullscreen mode

▢️ How to Run

  1. Save the script as check_balance.py
  2. Replace YOUR_RAPIDAPI_KEY with your RapidAPI key
  3. Run:
python check_balance.py
Enter fullscreen mode Exit fullscreen mode
  1. 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)