Agnic
Agnic Features

Balance

Check your wallet balance across networks

Balance

The Balance API returns your wallet's combined balance (USDC + credit), on-chain USDC balance, and address information.

Endpoint

GET /api/balance

Query Parameters

ParameterTypeDefaultDescription
networkstringbase-sepoliaBlockchain network to check

Supported Networks

NetworkDescription
base-sepoliaBase testnet (for development)
baseBase mainnet (production)

Response

{
  "usdcBalance": "50.000000",
  "creditBalance": "5.000000",
  "totalBalance": "55.000000",
  "address": "0x1234567890abcdef1234567890abcdef12345678",
  "hasWallet": true,
  "network": "base-sepolia",
  "chainType": "ethereum"
}
FieldTypeDescription
usdcBalancestringOn-chain USDC balance
creditBalancestringIn-app credit balance ("0" if no approved credit)
totalBalancestringCombined balance (USDC + credit)
addressstringYour wallet address
hasWalletbooleanWhether wallet has been created
networkstringNetwork queried
chainTypestringChain type (ethereum or solana)

Examples

Check Default Network Balance

curl https://api.agnic.ai/api/balance \
  -H "X-Agnic-Token: agnic_tok_YOUR_TOKEN"

Check Mainnet Balance

curl "https://api.agnic.ai/api/balance?network=base" \
  -H "X-Agnic-Token: agnic_tok_YOUR_TOKEN"

Python Example

import requests

response = requests.get(
    "https://api.agnic.ai/api/balance",
    headers={"X-Agnic-Token": "agnic_tok_YOUR_TOKEN"},
    params={"network": "base-sepolia"}
)

data = response.json()
print(f"Total Balance: ${data['totalBalance']}")
print(f"USDC: ${data['usdcBalance']} | Credit: ${data['creditBalance']}")
print(f"Address: {data['address']}")

JavaScript Example

const response = await fetch(
  'https://api.agnic.ai/api/balance?network=base-sepolia',
  {
    headers: {
      'X-Agnic-Token': 'agnic_tok_YOUR_TOKEN'
    }
  }
);

const { totalBalance, usdcBalance, creditBalance, address } = await response.json();
console.log(`Total Balance: $${totalBalance}`);
console.log(`USDC: $${usdcBalance} | Credit: $${creditBalance}`);
console.log(`Address: ${address}`);

Check Balance Before Transaction

import requests

def check_can_afford(amount_usd):
    response = requests.get(
        "https://api.agnic.ai/api/balance",
        headers={"X-Agnic-Token": "agnic_tok_YOUR_TOKEN"}
    )

    balance = float(response.json()["totalBalance"])
    return balance >= amount_usd

# Check if we can afford a $0.50 transaction
if check_can_afford(0.50):
    print("Sufficient balance")
else:
    print("Insufficient balance - please add funds")

Error Responses

Invalid Network

{
  "error": "invalid_network",
  "error_description": "Network 'invalid' is not supported"
}

No Wallet

{
  "usdcBalance": "0",
  "creditBalance": "5.000000",
  "totalBalance": "5.000000",
  "address": null,
  "hasWallet": false,
  "network": "base-sepolia",
  "chainType": "ethereum"
}