kamiPay LogokamiPay Docs

Address Balance

Check the balance of a specific wallet address

This endpoint allows you to check the balance in a given address. Balance will be provided for Matic and USDT only.

Query Parameters

NameTypeDescription
chainstringRequired. Only 'polygon' is accepted.
addressstringRequired. Address to check. It must be a previously assigned address to your user.

Example Request

const chain = "polygon";
const address = "0x1c0aCFxxxxxxxxxxA8fEdce1ab4";

const url = `${baseURL}/v1/wallet/get_address_balance?address=${address}&chain=${chain}`;

const response = await fetch(url, {
  method: "GET",
  headers: {
    Authorization: `Bearer ${access_token}`,
    "Content-Type": "application/json",
  },
});
import requests

chain = "polygon"
address = "0x1c0aCFxxxxxxxxxxA8fEdce1ab4"

url = f"{base_url}/v1/wallet/get_address_balance?address={address}&chain={chain}"

headers = {
    'Authorization': f'Bearer {access_token}',
    'Content-Type': 'application/json',
}

response = requests.get(url, headers=headers)
package main

import (
    "fmt"
    "io/ioutil"
    "net/http"
    "net/url"
)

func main() {
    chain := "polygon"
    address := "0x1c0aCFxxxxxxxxxxA8fEdce1ab4"
    
    // Create URL with query parameters
    baseURL := "https://api.kamipay.io"
    reqURL, _ := url.Parse(fmt.Sprintf("%s/v1/wallet/get_address_balance", baseURL))
    params := url.Values{}
    params.Add("address", address)
    params.Add("chain", chain)
    reqURL.RawQuery = params.Encode()
    
    // Create request
    req, _ := http.NewRequest("GET", reqURL.String(), nil)
    req.Header.Add("Authorization", fmt.Sprintf("Bearer %s", access_token))
    req.Header.Add("Content-Type", "application/json")
    
    // Make the request
    client := &http.Client{}
    resp, err := client.Do(req)
    if err != nil {
        fmt.Println("Error making request:", err)
        return
    }
    defer resp.Body.Close()
    
    // Read the response body
    body, _ := ioutil.ReadAll(resp.Body)
    fmt.Println(string(body))
}

Response

{
    "status": "ok",
    "msg": "Matic and USDt Balance",
    "data": {
        "address": "0x1c0aCFxxxxxxxxxxA8fEdce1ab4",
        "tokens": [
            {
                "token": "MATIC",
                "balance": 0.35916607409480106
            },
            {
                "token": "USDT",
                "balance": 1.758236
            }
        ]
    }
}
{
  "detail": "Incorrect Credentials or Incorrect chain. Only 'polygon' accepted"
}
{
  "detail": "an unexpected error occurred"
}

This endpoint provides real-time balance information for both MATIC (gas token) and USDT in the specified wallet address.

On this page