Exchange Rates API
Get current exchange rates for all supported cryptocurrencies.
Get All Rates
GET
/rates/
Returns current exchange rates for all active cryptocurrencies against USD.
Authentication
Requires OAuth 2.0 authentication with read scope.
Example Request
curl -X GET https://api.cryptofuse.io/rates/ \
-H "Authorization: Bearer your_access_token"
Response
Success Response (200 OK)
{
"base_currency": "USD",
"rates": {
"USDTERC20": "0.9999",
"USDCERC20": "1.0001",
"ETH": "2345.67",
"WETH": "2345.67",
"USDTTRC20": "0.9999",
"USDTPOLYGON": "0.9999",
"USDTBSC": "0.9999"
},
"last_updated": "2025-01-15T10:00:00Z",
"next_update": "2025-01-15T10:01:00Z"
}
Response Fields
| Field | Type | Description |
|---|---|---|
base_currency | string | Base currency for rates (always "USD") |
rates | object | Exchange rates keyed by currency code |
last_updated | datetime | When rates were last updated |
next_update | datetime | When rates will be refreshed |
Rate Updates
- Rates are updated every 60 seconds
- Stablecoin rates typically stay near 1.0
- Volatile assets (ETH, BTC) may change significantly
- All rates are in USD
Get Specific Rate
GET
/rates/{currency}/
Get the exchange rate for a specific cryptocurrency.
Authentication
Requires OAuth 2.0 authentication with read scope.
Path Parameters
| Parameter | Type | Description |
|---|---|---|
currency | string | Currency code (e.g., "USDTERC20") |
Example Request
curl -X GET https://api.cryptofuse.io/rates/USDTERC20/ \
-H "Authorization: Bearer your_access_token"
Response
Success Response (200 OK)
{
"currency": "USDTERC20",
"rate_usd": "0.9999",
"change_24h": "-0.01",
"change_24h_percent": "-0.01",
"high_24h": "1.0002",
"low_24h": "0.9997",
"volume_24h": "1234567890.00",
"market_cap": "83456789012.00",
"last_updated": "2025-01-15T10:00:00Z"
}
Response Fields
| Field | Type | Description |
|---|---|---|
currency | string | Currency code |
rate_usd | string | Current USD exchange rate |
change_24h | string | 24-hour price change in USD |
change_24h_percent | string | 24-hour percentage change |
high_24h | string | 24-hour high price |
low_24h | string | 24-hour low price |
volume_24h | string | 24-hour trading volume in USD |
market_cap | string | Market capitalization in USD |
last_updated | datetime | Last update timestamp |
Error Responses
404 Not Found
{
"error": {
"code": "not_found",
"message": "Currency not found",
"details": {
"currency": "FAKECOIN"
}
}
}
Calculate Exchange Amount
POST
/rates/calculate/
Calculate the equivalent amount between currencies with fee calculation.
Request Body
| Parameter | Type | Required | Description |
|---|---|---|---|
amount | decimal | Yes | Amount to convert |
from_currency | string | Yes | Source currency code |
to_currency | string | Yes | Target currency code |
is_fee_paid_by_user | boolean | No | Include fees in calculation (default: true) |
See Payment Estimation for full documentation of this endpoint.
Usage Examples
Display Current Rates
async function displayRates(accessToken) {
const response = await fetch('https://api.cryptofuse.io/rates/', {
headers: {
'Authorization': `Bearer ${accessToken}`
}
});
const data = await response.json();
// Display stablecoin rates
console.log('Stablecoin Rates:');
console.log(`USDT (ERC20): ${data.rates.USDTERC20}`);
console.log(`USDC (ERC20): ${data.rates.USDCERC20}`);
console.log(`USDT (TRC20): ${data.rates.USDTTRC20}`);
// Display crypto rates
console.log('\nCrypto Rates:');
console.log(`ETH: ${data.rates.ETH}`);
// Calculate time until next update
const nextUpdate = new Date(data.next_update);
const now = new Date();
const secondsUntilUpdate = Math.floor((nextUpdate - now) / 1000);
console.log(`\nRates refresh in ${secondsUntilUpdate} seconds`);
}
Rate Monitoring
import asyncio
import aiohttp
from datetime import datetime
class RateMonitor:
def __init__(self, access_token):
self.access_token = access_token
self.previous_rates = {}
async def check_rates(self):
"""Check rates and alert on significant changes."""
async with aiohttp.ClientSession() as session:
async with session.get(
'https://api.cryptofuse.io/rates/',
headers={'Authorization': f'Bearer {self.access_token}'}
) as response:
data = await response.json()
for currency, rate in data['rates'].items():
rate = float(rate)
if currency in self.previous_rates:
previous = self.previous_rates[currency]
change_percent = ((rate - previous) / previous) * 100
# Alert on >1% change
if abs(change_percent) > 1.0:
print(f"🚨 {currency} changed {change_percent:.2f}%")
print(f" {previous:.4f} → {rate:.4f}")
self.previous_rates[currency] = rate
print(f"✓ Rates updated at {datetime.now()}")
async def run(self):
"""Run continuous monitoring."""
while True:
await self.check_rates()
await asyncio.sleep(60) # Check every minute
# Usage
monitor = RateMonitor('your_access_token')
asyncio.run(monitor.run())
Rate Caching
class RateCache {
constructor(ttl = 60000) { // 60 seconds TTL
this.cache = new Map();
this.ttl = ttl;
}
async getRates(accessToken) {
const cached = this.cache.get('rates');
if (cached && cached.expires > Date.now()) {
console.log('Using cached rates');
return cached.data;
}
console.log('Fetching fresh rates');
const response = await fetch('https://api.cryptofuse.io/rates/', {
headers: {
'Authorization': `Bearer ${accessToken}`
}
});
const data = await response.json();
this.cache.set('rates', {
data: data,
expires: Date.now() + this.ttl
});
return data;
}
async getRate(currency, accessToken) {
const rates = await this.getRates(accessToken);
return rates.rates[currency];
}
}
// Usage
const accessToken = 'your_access_token';
const rateCache = new RateCache();
// First call fetches from API
const usdtRate = await rateCache.getRate('USDTERC20', accessToken);
// Subsequent calls use cache (within 60 seconds)
const usdcRate = await rateCache.getRate('USDCERC20', accessToken);
Important Notes
- Rates are provided for informational purposes
- Actual payment amounts may vary slightly due to market volatility
- Always use the
/rates/calculate/endpoint for accurate payment calculations - Rates include all active cryptocurrencies in the system
- Disabled currencies are excluded from rate responses