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/balance/{address}
GET https://api-testnet11.spacescan.io/address/balance/{address}
Parameters
Parameter | Type | Description |
---|---|---|
address | string | The XCH address |
Use api.spacescan.io
for free tier access. See our API Plans for rate limits and features.
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/balance/{address}" \
-H "x-api-key: YOUR_API_KEY"
Live API Test
- Mainnet
- Testnet
Request Example
- cURL
- Python
- JavaScript
- Mainnet
- Testnet
import requests
address = "xch1a6cd558gqsz2hch5pt0l8mx7zhavf32q5lyde09zjtqcmkelr9ns59k0j8"
url = f"https://api.spacescan.io/address/balance/{address}"
response = requests.get(url)
data = response.json()
print(data)
import requests
address = "xch1a6cd558gqsz2hch5pt0l8mx7zhavf32q5lyde09zjtqcmkelr9ns59k0j8"
url = f"https://api-testnet11.spacescan.io/address/balance/{address}"
response = requests.get(url)
data = response.json()
print(data)
- Mainnet
- Testnet
const address = "xch1a6cd558gqsz2hch5pt0l8mx7zhavf32q5lyde09zjtqcmkelr9ns59k0j8";
const url = https://api.spacescan.io/address/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/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 |
---|---|---|
balance | object | XCH balance information |
balance.mojo | number | The XCH balance in mojos |
balance.xch | number | The XCH balance in XCH |
balance.usd | number | The USD value of the XCH balance |