Get Wallet Balance
curl --request GET \
--url https://api.magebank.ai/user/wallet-balance \
--header 'x-api-key: <x-api-key>'import requests
url = "https://api.magebank.ai/user/wallet-balance"
headers = {"x-api-key": "<x-api-key>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {'x-api-key': '<x-api-key>'}};
fetch('https://api.magebank.ai/user/wallet-balance', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.magebank.ai/user/wallet-balance",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"x-api-key: <x-api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.magebank.ai/user/wallet-balance"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("x-api-key", "<x-api-key>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.magebank.ai/user/wallet-balance")
.header("x-api-key", "<x-api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.magebank.ai/user/wallet-balance")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["x-api-key"] = '<x-api-key>'
response = http.request(request)
puts response.read_body{
"success": true,
"balance": "100.50",
"asset": "USDC"
}
{
"success": true,
"balance": "0.05",
"asset": "ETH"
}
{
"success": true,
"balance": "0.00",
"message": "All balance fetching methods failed"
}
{
"error": "Invalid wallet address format"
}
{
"error": "Invalid or missing API key"
}
{
"error": "Unexpected error"
}
Users
Get Wallet Balance
Retrieve the authenticated user’s wallet balance from the blockchain
GET
/
user
/
wallet-balance
Get Wallet Balance
curl --request GET \
--url https://api.magebank.ai/user/wallet-balance \
--header 'x-api-key: <x-api-key>'import requests
url = "https://api.magebank.ai/user/wallet-balance"
headers = {"x-api-key": "<x-api-key>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {'x-api-key': '<x-api-key>'}};
fetch('https://api.magebank.ai/user/wallet-balance', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.magebank.ai/user/wallet-balance",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"x-api-key: <x-api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.magebank.ai/user/wallet-balance"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("x-api-key", "<x-api-key>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.magebank.ai/user/wallet-balance")
.header("x-api-key", "<x-api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.magebank.ai/user/wallet-balance")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["x-api-key"] = '<x-api-key>'
response = http.request(request)
puts response.read_body{
"success": true,
"balance": "100.50",
"asset": "USDC"
}
{
"success": true,
"balance": "0.05",
"asset": "ETH"
}
{
"success": true,
"balance": "0.00",
"message": "All balance fetching methods failed"
}
{
"error": "Invalid wallet address format"
}
{
"error": "Invalid or missing API key"
}
{
"error": "Unexpected error"
}
Retrieves the user’s wallet balance from the blockchain using their wallet address. The endpoint follows a fallback strategy, first attempting to fetch USDC balance, then ETH, and finally any other non-zero balance.
Request Headers
string
required
Your API key for authentication
Response
boolean
Whether the balance retrieval was successful
string
Current wallet balance formatted as a string to preserve precision
string
Asset type (USDC, ETH, or other cryptocurrency)
string
Additional information about the balance retrieval (appears when balance fetching methods fail)
{
"success": true,
"balance": "100.50",
"asset": "USDC"
}
{
"success": true,
"balance": "0.05",
"asset": "ETH"
}
{
"success": true,
"balance": "0.00",
"message": "All balance fetching methods failed"
}
{
"error": "Invalid wallet address format"
}
{
"error": "Invalid or missing API key"
}
{
"error": "Unexpected error"
}
Status Codes
| Status Code | Description |
|---|---|
| 200 | Wallet balance retrieved successfully |
| 400 | Bad Request - Invalid wallet address format |
| 401 | Unauthorized - Invalid or missing API key |
| 500 | Unexpected error |
Notes
- Requires authentication with a valid API key.
- The endpoint uses a fallback strategy: first checks USDC, then ETH, and finally any other non-zero balance.
- Balance is returned as a string to preserve precision for financial calculations.
- If all balance fetching methods fail, the API will return a successful response with a zero balance and an explanatory message.