Get XCH Balance
This endpoint allows you to fetch the XCH balance for a given address.
Endpoint
- Mainnet
- Testnet
GET https://api.spacescan.io/address/xch-balance/{address}
GET https://api-testnet11.spacescan.io/address/xch-balance/{address}
Parameters
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
address | string | Yes | - | The XCH address to fetch balance for |
include_dust | boolean | No | false | Include dust coins in balance |
Free API
Use api.spacescan.io
for free tier access. See our API Plans for rate limits and features.
Pro API
Use pro-api.spacescan.io
with your API key in the x-api-key
header. See our API Plans for details.
curl -X GET "https://pro-api.spacescan.io/address/xch-balance/{address}" \
-H "x-api-key: YOUR_API_KEY"
Live API Test
- Mainnet
- Testnet
Request Examples
- cURL
- Python
- JavaScript
- Mainnet
- Testnet
curl -X GET "https://api.spacescan.io/address/xch-balance/xch1a6cd558gqsz2hch5pt0l8mx7zhavf32q5lyde09zjtqcmkelr9ns59k0j8"
curl -X GET "https://api-testnet11.spacescan.io/address/xch-balance/xch1a6cd558gqsz2hch5pt0l8mx7zhavf32q5lyde09zjtqcmkelr9ns59k0j8"
- Mainnet
- Testnet
import requests
address = "xch1a6cd558gqsz2hch5pt0l8mx7zhavf32q5lyde09zjtqcmkelr9ns59k0j8"
url = f"https://api.spacescan.io/address/xch-balance/{address}"
response = requests.get(url)
data = response.json()
print(data)
import requests
address = "xch1a6cd558gqsz2hch5pt0l8mx7zhavf32q5lyde09zjtqcmkelr9ns59k0j8"
url = f"https://api-testnet11.spacescan.io/address/xch-balance/{address}"
response = requests.get(url)
data = response.json()
print(data)
- Mainnet
- Testnet
const address = "xch1a6cd558gqsz2hch5pt0l8mx7zhavf32q5lyde09zjtqcmkelr9ns59k0j8";
const url = `https://api.spacescan.io/address/xch-balance/${address}`;
fetch(url)
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));
const address = "xch1a6cd558gqsz2hch5pt0l8mx7zhavf32q5lyde09zjtqcmkelr9ns59k0j8";
const url = `https://api-testnet11.spacescan.io/address/xch-balance/${address}`;
fetch(url)
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));
Response
- Mainnet
- Testnet
Failed to load API response. Please try again later.
Failed to load API response. Please try again later.
Response Schema
Field | Type | Description |
---|---|---|
status | string | Success or failure status |
xch | number | Balance in XCH |
mojo | number | Balance in mojo |
Notes
- The balance includes all unspent coins for the address
- Set include_dust=true to include dust coins in the balance