Get XCH Price
This endpoint allows you to fetch the XCH price for a specific period and currency.
Endpoint
- Mainnet
- Testnet
GET https://api.spacescan.io/stats/price
GET https://api-testnet11.spacescan.io/stats/price
Parameters
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
period | number | No | current time | Unix timestamp for historical price |
currency | string | No | USD | Currency code (e.g., USD, EUR, GBP) |
network | string | No | mainnet | Network to query |
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/stats/price" \
-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/stats/price?currency=USD&period=1677649200"
curl -X GET "https://api-testnet11.spacescan.io/stats/price?currency=USD&period=1677649200"
- Mainnet
- Testnet
import requests
url = "https://api.spacescan.io/stats/price"
params = {
"currency": "USD",
"period": 1677649200
}
response = requests.get(url, params=params)
data = response.json()
print(data)
import requests
url = "https://api-testnet11.spacescan.io/stats/price"
params = {
"currency": "USD",
"period": 1677649200
}
response = requests.get(url, params=params)
data = response.json()
print(data)
- Mainnet
- Testnet
const url = new URL("https://api.spacescan.io/stats/price");
url.searchParams.append("currency", "USD");
url.searchParams.append("period", "1677649200");
fetch(url)
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));
const url = new URL("https://api-testnet11.spacescan.io/stats/price");
url.searchParams.append("currency", "USD");
url.searchParams.append("period", "1677649200");
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 |
price | number | XCH price in requested currency |
Notes
- If no period is specified, returns the current price
- Historical prices may not be available for all timestamps
- Supported currencies include USD, EUR, GBP, and others