rabbitforexapi
Real time exchange rate data
2.5K
A high-performance foreign exchange (Forex), precious metals, stocks, and cryptocurrency API built with Bun that fetches real-time exchange rate data from multiple sources and serves it through a REST API.
Create a .env file in your project root:
# Server Configuration
SERVER_HOST="0.0.0.0"
SERVER_PORT=3000
# Wise API Configuration
# Get your API key from https://wise.com (Read Only)
# Required for fetching forex rates
WISE_API_KEY="your_wise_api_key_here"
# Update Interval (in seconds)
# How often to fetch new exchange rates from Wise API
# Default: 30 (30 seconds)
UPDATE_INTERVAL=30
# Trading212 Configuration
# Get your API key from https://www.trading212.com
TRADING212_API_KEY="your_trading212_api_key_here"
TRADING212_API_SECRET="your_trading212_api_secret_here"
# Stock Update Interval (in seconds)
# How often to fetch new stock prices from Trading212 API
# Default: 30 (30 seconds) - Minimum: 10 (10 seconds)
STOCK_UPDATE_INTERVAL=30
# Crypto Exchange Configuration
# Enable or disable fetching prices from crypto exchanges
USE_KRAKEN=true
USE_BINANCE=true
USE_GATEIO=true
USE_KUCOIN=true
USE_BINGX=true
USE_BYBIT=true
USE_CRYPTOCOM=true
USE_BITFINEX=true
# How often to fetch cryptocurrency prices from enabled crypto exchanges (in seconds)
# Default: 30 (30 seconds)
CRYPTO_UPDATE_INTERVAL=30
# Cryptocurrencies to monitor (comma-separated list)
# Example: BTC,ETH,SOL,ADA,XRP
ENABLED_CRYPTOS=AAVE,ADA,ALGO,ARB,ATOM,AVAX,BCH,BNB,BTC,CELO,CRO,DASH,DOGE,DOT,EGLD,EOS,ETC,ETH,FIL,FLOW,GRT,HNT,ICP,IMX,INJ,IOTA,KAS,LINK,LTC,MINA,NANO,NEAR,NEO,POL,QTUM,RUNE,RVN,S,SEI,SOL,STX,THETA,TIA,TON,TRX,VET,WAVES,XLM,XMR,XRP,XTZ,ZEC,ZIL
# Logging Configuration
# 0 = ERROR, 1 = WARN, 2 = AUDIT, 3 = INFO, 4 = HTTP, 5 = DEBUG, 6 = VERBOSE, 7 = SILLY
# Default: 3 (INFO) - Recommended: 3 for production, 5 for development
LOGGER_LEVEL=3
# Proxy Configuration
# Important: Set this to match your deployment environment to prevent IP spoofing
# Options: "aws" (AWS ELB/ALB), "azure" (Azure), "cloudflare" (Cloudflare),
# "gcp" (Google Cloud), "nginx" (Nginx), "vercel" (Vercel),
# "direct" (no proxy/development), "development" (dev with proxy headers)
# Default: "direct"
PROXY=direct
# Enable or disable OpenMetrics endpoint
# Default: false
OPEN_METRICS_ENABLED=false
# Protect OpenMetrics API endpoint with Bearer authentication
# Set to "none" to disable authentication (not recommended for production)
# Default: none
OPEN_METRICS_AUTH_TOKEN=none
# Enable/disable history recording
HISTORY_ENABLED=true
# ClickHouse Connection
CLICKHOUSE_HOST=clickhouse
CLICKHOUSE_PORT=8123
CLICKHOUSE_DATABASE=rabbitforex
CLICKHOUSE_USERNAME=rabbitforex_user
CLICKHOUSE_PASSWORD=rabbitforex_password
# ClickHouse Performance Settings
CLICKHOUSE_COMPRESSION=true
CLICKHOUSE_MAX_CONNECTIONS=10
CLICKHOUSE_TIMEOUT=30000
docker-compose up -d
docker run -d \
--name rabbitforexapi \
-p 3000:3000 \
-e WISE_API_KEY="your_wise_api_key_here" \
-e UPDATE_INTERVAL=30 \
-e TRADING212_API_KEY="your_trading212_api_key_here" \
-e TRADING212_API_SECRET="your_trading212_api_secret_here" \
-e STOCK_UPDATE_INTERVAL=30 \
-e CRYPTO_UPDATE_INTERVAL=30 \
-e ENABLED_CRYPTOS="BTC,ETH,SOL,ADA,XRP" \
-e LOGGER_LEVEL=3 \
-e PROXY=direct \
rabbitcompany/rabbitforexapi:latest
/Health Check and Statistics
{
"program": "RabbitForexAPI",
"version": "4.1.0",
"sourceCode": "https://github.com/Rabbit-Company/RabbitForexAPI",
"monitorStats": {
"currencyCount": 162,
"metalCount": 4,
"cryptoCount": 2886,
"stockCount": 23,
"totalAssetCount": 3075,
"updateInterval": "30s",
"historyEnabled": true
},
"httpStats": {
"pendingRequests": 1
},
"lastUpdate": "2025-11-07T07:07:54.995Z"
}
/metricsReturns metrics in OpenMetrics format for Prometheus monitoring.
Authentication: Protected with Bearer token (configure via OPEN_METRICS_AUTH_TOKEN environment variable)
Response: OpenMetrics text format
Example:
# TYPE rabbitforex_http_requests counter
# HELP rabbitforex_http_requests Total HTTP requests
rabbitforex_http_requests_total 0 1764012335.777
rabbitforex_http_requests_total{endpoint="/metrics"} 52 1764012466.32
rabbitforex_http_requests_total{endpoint="/"} 18 1764012414.1
rabbitforex_http_requests_created 1764012335.777 1764012335.777
rabbitforex_http_requests_created{endpoint="/metrics"} 1764012396.269 1764012466.32
rabbitforex_http_requests_created{endpoint="/"} 1764012410.614 1764012414.1
# EOF
/openapi.jsonOpenAPI specification
/v1/ratesGet all exchange rates with USD as base (default)
{
"base": "USD",
"rates": {
"USD": 1,
"EUR": 0.86702,
"JPY": 153.4793,
"GBP": 0.7624,
"CHF": 0.80776,
"...": "..."
},
"timestamps": {
"currency": "2025-11-07T07:06:10.544Z"
}
}
/v1/rates/:assetGet all exchange rates with specified asset as base
Example: /v1/rates/EUR - Euro as base
{
"base": "EUR",
"rates": {
"EUR": 1,
"USD": 1.1534,
"JPY": 177.02,
"GBP": 0.87934,
"...": "..."
},
"timestamps": {
"currency": "2025-11-07T07:06:10.544Z"
}
}
/v1/rates/history/:symbolGet raw price history for a currency (last 24 hours)
Example: /v1/rates/history/EUR
{
"symbol": "EUR",
"base": "USD",
"resolution": "raw",
"data": [
{
"timestamp": "2025-11-07T06:30:00.000Z",
"price": 1.0892
},
{
"timestamp": "2025-11-07T06:30:30.000Z",
"price": 1.0895
}
]
}
/v1/rates/history/:symbol/hourlyGet hourly aggregated price history for a currency (last 90 days)
Example: /v1/rates/history/EUR/hourly
{
"symbol": "EUR",
"base": "USD",
"resolution": "hourly",
"data": [
{
"timestamp": "2025-11-07T06:00:00Z",
"avg": 1.0898,
"min": 1.0885,
"max": 1.0912,
"open": 1.0892,
"close": 1.0905,
"sampleCount": 120
}
]
}
/v1/rates/history/:symbol/dailyGet daily aggregated price history for a currency (all time)
Example: /v1/rates/history/EUR/daily
{
"symbol": "EUR",
"base": "USD",
"resolution": "daily",
"data": [
{
"timestamp": "2025-11-07",
"avg": 1.09,
"min": 1.085,
"max": 1.095,
"open": 1.0875,
"close": 1.092,
"sampleCount": 2880
}
]
}
/v1/metals/ratesGet all metal rates with USD as base (default)
{
"base": "USD",
"rates": {
"GOLD": 0.0077614,
"SILVER": 0.63833,
"PLATINUM": 0.020007,
"COPPER": 93.4827
},
"timestamps": {
"currency": "2025-11-07T07:06:10.544Z",
"metal": "2025-11-07T07:06:07.016Z"
}
}
/v1/metals/rates/:assetGet all metal rates with specified asset as base (currency or metal)
Example: /v1/metals/rates/GOLD - Gold as base
{
"base": "GOLD",
"rates": {
"USD": 128.8432,
"EUR": 111.7092,
"JPY": 19774.7612,
"GBP": 98.2304,
"...": "..."
},
"timestamps": {
"currency": "2025-11-07T07:06:10.544Z",
"metal": "2025-11-07T07:06:07.016Z"
}
}
Example: /v1/metals/rates/EUR - Euro as base
{
"base": "EUR",
"rates": {
"GOLD": 0.0081904,
"SILVER": 0.67794,
"PALLADIUM": 0.023327,
"COPPER": 108.0754
},
"timestamps": {
"currency": "2025-11-09T21:00:31.465Z",
"metal": "2025-11-09T21:00:31.153Z"
}
}
/v1/metals/history/:symbolGet raw price history for a metal (last 24 hours)
Example: /v1/metals/history/GOLD
{
"symbol": "GOLD",
"base": "USD",
"resolution": "raw",
"data": [
{
"timestamp": "2025-11-07T06:30:00.000Z",
"price": 4332.32
}
]
}
/v1/metals/history/:symbol/hourlyGet hourly aggregated price history for a metal (last 90 days)
Example: /v1/metals/history/GOLD/hourly
{
"symbol": "GOLD",
"base": "USD",
"resolution": "hourly",
"data": [
{
"timestamp": "2025-11-07T06:00:00Z",
"avg": 4332.32,
"min": 4246.65,
"max": 4374.73,
"open": 4314.41,
"close": 4353.63,
"sampleCount": 120
}
]
}
/v1/metals/history/:symbol/dailyGet daily aggregated price history for a metal (all time)
Example: /v1/metals/history/GOLD/daily
{
"symbol": "GOLD",
"base": "USD",
"resolution": "daily",
"data": [
{
"timestamp": "2025-11-07",
"avg": 4332.32,
"min": 4246.65,
"max": 4374.73,
"open": 4314.41,
"close": 4353.63,
"sampleCount": 2880
}
]
}
/v1/crypto/ratesGet all cryptocurrency rates with USD as base (default)
{
"base": "USD",
"rates": {
"BTC": 0.0000098082,
"ETH": 0.00029232,
"SOL": 0.0062949,
"ADA": 1.7876,
"XRP": 0.4379,
"DOT": 0.32144,
"...": "..."
},
"timestamps": {
"currency": "2025-11-07T07:06:10.544Z",
"crypto": "2025-11-07T07:06:05.123Z"
}
}
/v1/crypto/rates/:assetGet all cryptocurrency rates with specified asset as base (currency or cryptocurrency)
Example: /v1/crypto/rates/BTC - Bitcoin as base
{
"base": "BTC",
"rates": {
"USD": 101565.0019,
"EUR": 87787.71,
"...": "..."
},
"timestamps": {
"currency": "2025-11-07T07:06:10.544Z",
"crypto": "2025-11-07T07:06:05.123Z"
}
}
Example: /v1/crypto/rates/EUR - Euro as base for crypto rates
{
"base": "EUR",
"rates": {
"BTC": 0.000011571,
"ETH": 0.00034673,
"SOL": 0.0074452,
"ADA": 2.1322,
"XRP": 0.52006,
"DOT": 0.38543,
"...": "..."
},
"timestamps": {
"currency": "2025-11-07T07:06:10.544Z",
"crypto": "2025-11-07T07:06:05.123Z"
}
}
/v1/crypto/history/:symbolGet raw price history for a cryptocurrency (last 24 hours)
Example: /v1/crypto/history/BTC
{
"symbol": "BTC",
"base": "USD",
"resolution": "raw",
"data": [
{
"timestamp": "2025-11-07T06:30:00.000Z",
"price": 97500.1234
},
{
"timestamp": "2025-11-07T06:30:30.000Z",
"price": 97520.5678
}
]
}
/v1/crypto/history/:symbol/hourlyGet hourly aggregated price history for a cryptocurrency (last 90 days)
Example: /v1/crypto/history/BTC/hourly
{
"symbol": "BTC",
"base": "USD",
"resolution": "hourly",
"data": [
{
"timestamp": "2025-11-07T06:00:00Z",
"avg": 97500.0,
"min": 96000.0,
"max": 99000.0,
"open": 96500.0,
"close": 98000.0,
"sampleCount": 120
}
]
}
/v1/crypto/history/:symbol/dailyGet daily aggregated price history for a cryptocurrency (all time)
Example: /v1/crypto/history/BTC/daily
{
"symbol": "BTC",
"base": "USD",
"resolution": "daily",
"data": [
{
"timestamp": "2025-11-07",
"avg": 97500.0,
"min": 95000.0,
"max": 100000.0,
"open": 96000.0,
"close": 99000.0,
"sampleCount": 2880
}
]
}
/v1/stocks/ratesGet all stock rates with USD as base (default)
{
"base": "USD",
"rates": {
"VOW3d": 0.01227,
"NET": 0.004275,
"MSFT": 0.0020088,
"ASMLa": 0.0013276,
"V": 0.0029717,
"UBNT": 0.0016181,
"SMSDl": 0.00078125,
"FB": 0.0015993,
"...": "..."
},
"timestamps": {
"currency": "2025-11-07T07:06:10.544Z",
"stock": "2025-11-07T07:06:05.123Z"
}
}
/v1/stocks/rates/:assetGet all stock rates with specified asset as base (currency or stock)
Example: /v1/stocks/rates/NET - Cloudflare as base
{
"base": "NET",
"rates": {
"USD": 233.92,
"HRK": 35.8903,
"GHS": 21.4114,
"BSD": 233.92,
"BAM": 138.2631,
"...": "..."
},
"timestamps": {
"currency": "2025-11-07T07:06:10.544Z",
"stock": "2025-11-07T07:06:05.123Z"
}
}
Example: /v1/stocks/rates/EUR - Euro as base for stock rates
{
"base": "EUR",
"rates": {
"VOW3d": 0.010613,
"NET": 0.0036976,
"MSFT": 0.0017375,
"ASMLa": 0.0011484,
"V": 0.0025703,
"UBNT": 0.0013996,
"SMSDl": 0.00067573,
"FB": 0.0013833,
"...": "..."
},
"timestamps": {
"currency": "2025-11-07T07:06:10.544Z",
"stock": "2025-11-07T07:06:05.123Z"
}
}
/v1/stocks/history/:symbolGet raw price history for a stock (last 24 hours)
Example: /v1/stocks/history/NET
{
"symbol": "NET",
"base": "USD",
"resolution": "raw",
"data": [
{
"timestamp": "2025-11-07T06:30:00.000Z",
"price": 196.1853
},
{
"timestamp": "2025-11-07T06:30:30.000Z",
"price": 198.9521
}
]
}
/v1/stocks/history/:symbol/hourlyGet hourly aggregated price history for a stock (last 90 days)
Example: /v1/stocks/history/NET/hourly
{
"symbol": "NET",
"base": "USD",
"resolution": "hourly",
"data": [
{
"timestamp": "2025-11-07T06:00:00Z",
"avg": 197.1243,
"min": 184.5493,
"max": 210.4347,
"open": 186.9825,
"close": 205.7362,
"sampleCount": 120
}
]
}
/v1/stocks/history/:symbol/dailyGet daily aggregated price history for a stock (all time)
Example: /v1/stocks/history/NET/daily
{
"symbol": "NET",
"base": "USD",
"resolution": "daily",
"data": [
{
"timestamp": "2025-11-07",
"avg": 197.1243,
"min": 184.5493,
"max": 210.4347,
"open": 186.9825,
"close": 205.7362,
"sampleCount": 2880
}
]
}
/v1/assetsGet lists of all supported currencies, metals and cryptocurrencies
{
"currencies": ["AED", "AFN", "ALL", "AMD", "ANG", "AOA", "ARS", "AUD", "EUR", "USD", "GBP", "JPY", "CHF", "CAD", "..."],
"metals": ["GOLD", "SILVER", "PALLADIUM", "COPPER"],
"cryptocurrencies": ["BTC", "ETH", "SOL", "ADA", "XRP", "DOT", "DOGE", "AVAX", "LINK", "..."],
"stocks": ["VOW3d", "NET", "MSFT", "ASMLa", "V", "UBNT", "SMSDl", "FB", "..."],
"timestamps": {
"currency": "2025-11-07T07:06:10.544Z",
"metal": "2025-11-07T07:06:07.016Z",
"crypto": "2025-11-07T07:06:05.123Z",
"stock": "2025-11-07T07:06:05.123Z"
}
}
The API supports historical price data storage and retrieval using ClickHouse. When HISTORY_ENABLED=true, prices are recorded and aggregated at multiple resolutions.
| Resolution | Endpoint Suffix | Data Retention | Cache TTL |
|---|---|---|---|
| Raw | (none) | 1 day | 30 seconds |
| Hourly | /hourly | 90 days | 5 minutes |
| Daily | /daily | Forever | 1 hour |
An aggregation job runs every 10 minutes to compute:
Raw data includes:
price - The price at that momenttimestamp - ISO 8601 timestampAggregated data (hourly/daily) includes:
timestamp - Period start timeavg - Average price in the periodmin - Minimum price in the periodmax - Maximum price in the periodopen - Opening price (first price)close - Closing price (last price)sampleCount - Number of data pointsThe API supports 150+ currencies, including:
The API supports various stocks from major exchanges including:
The API supports 2500+ major cryptocurrencies, including:
Exchange rates are calculated using USD as the reference currency from Wise data:
Rates are rounded intelligently based on their magnitude:
Stock prices are fetched from Trading212 API:
Cryptocurrency prices are aggregated from multiple exchanges for optimal pricing:
Rates are rounded intelligently based on their magnitude:
Content type
Image
Digest
sha256:151f049cbโฆ
Size
40.6 MB
Last updated
29 days ago
docker pull rabbitcompany/rabbitforexapi