Market data access provides comprehensive functionality to fetch public market information including trading pairs, price tickers, order books, trade history, and OHLCV candlestick data from any supported exchange.
Load and cache trading pair information for the exchange.
/**
* Load all available markets for the exchange
* This method must be called before using symbol-based methods
*/
loadMarkets(reload?: boolean, params?: object): Promise<Dictionary<Market>>;
/**
* Fetch fresh market data from exchange
*/
fetchMarkets(params?: object): Promise<Market[]>;Usage Examples:
const exchange = new ccxt.binance();
// Load markets (cached after first call)
const markets = await exchange.loadMarkets();
console.log(Object.keys(markets)); // ['BTC/USDT', 'ETH/USDT', ...]
// Force reload markets
const freshMarkets = await exchange.loadMarkets(true);
// Direct fetch without caching
const marketList = await exchange.fetchMarkets();Fetch current price information and 24-hour statistics.
/**
* Fetch ticker for a single trading pair
*/
fetchTicker(symbol: string, params?: object): Promise<Ticker>;
/**
* Fetch tickers for multiple trading pairs
*/
fetchTickers(symbols?: string[], params?: object): Promise<Dictionary<Ticker>>;Usage Examples:
const exchange = new ccxt.binance();
await exchange.loadMarkets();
// Single ticker
const ticker = await exchange.fetchTicker('BTC/USDT');
console.log(`${ticker.symbol}: $${ticker.last}`);
console.log(`24h change: ${ticker.percentage}%`);
console.log(`Volume: ${ticker.baseVolume} BTC`);
// Multiple tickers
const tickers = await exchange.fetchTickers(['BTC/USDT', 'ETH/USDT']);
Object.values(tickers).forEach(ticker => {
console.log(`${ticker.symbol}: $${ticker.last}`);
});
// All tickers (if supported)
const allTickers = await exchange.fetchTickers();Fetch current bid and ask orders for trading pairs.
/**
* Fetch order book for a single trading pair
*/
fetchOrderBook(symbol: string, limit?: number, params?: object): Promise<OrderBook>;
/**
* Fetch order books for multiple trading pairs
*/
fetchOrderBooks(symbols?: string[], limit?: number, params?: object): Promise<Dictionary<OrderBook>>;Usage Examples:
const exchange = new ccxt.binance();
await exchange.loadMarkets();
// Basic order book
const orderbook = await exchange.fetchOrderBook('BTC/USDT');
console.log('Top bid:', orderbook.bids[0]); // [price, amount]
console.log('Top ask:', orderbook.asks[0]); // [price, amount]
// Limited depth order book
const limitedBook = await exchange.fetchOrderBook('BTC/USDT', 10);
console.log(`Bids: ${limitedBook.bids.length}`); // Max 10
console.log(`Asks: ${limitedBook.asks.length}`); // Max 10
// Multiple order books
const books = await exchange.fetchOrderBooks(['BTC/USDT', 'ETH/USDT'], 5);Fetch recent public trades for trading pairs.
/**
* Fetch recent public trades
*/
fetchTrades(symbol: string, since?: number, limit?: number, params?: object): Promise<Trade[]>;Usage Examples:
const exchange = new ccxt.binance();
await exchange.loadMarkets();
// Recent trades
const trades = await exchange.fetchTrades('BTC/USDT');
trades.forEach(trade => {
console.log(`${trade.side} ${trade.amount} at $${trade.price}`);
});
// Trades since timestamp
const yesterday = Date.now() - 24 * 60 * 60 * 1000;
const recentTrades = await exchange.fetchTrades('BTC/USDT', yesterday);
// Limited number of trades
const last10Trades = await exchange.fetchTrades('BTC/USDT', undefined, 10);Fetch historical price and volume data in candlestick format.
/**
* Fetch OHLCV candlestick data
*/
fetchOHLCV(
symbol: string,
timeframe?: string,
since?: number,
limit?: number,
params?: object
): Promise<OHLCV[]>;
// Available timeframes (exchange-dependent)
type Timeframe = '1m' | '3m' | '5m' | '15m' | '30m' | '1h' | '2h' | '4h' | '6h' | '8h' | '12h' | '1d' | '3d' | '1w' | '1M';Usage Examples:
const exchange = new ccxt.binance();
await exchange.loadMarkets();
// Basic OHLCV (1 hour candles)
const ohlcv = await exchange.fetchOHLCV('BTC/USDT', '1h');
ohlcv.forEach(candle => {
const [timestamp, open, high, low, close, volume] = candle;
console.log(`${new Date(timestamp)}: O:${open} H:${high} L:${low} C:${close} V:${volume}`);
});
// Specific timeframe and period
const dailyCandles = await exchange.fetchOHLCV('BTC/USDT', '1d', undefined, 30);
// Historical data from specific date
const startDate = Date.parse('2024-01-01');
const historicalData = await exchange.fetchOHLCV('BTC/USDT', '1h', startDate, 100);Fetch information about available currencies and tokens.
/**
* Fetch currency/token information
*/
fetchCurrencies(params?: object): Promise<Dictionary<Currency>>;
interface Currency {
id: string;
code: string;
name?: string;
active: boolean;
deposit?: boolean;
withdraw?: boolean;
fee?: number;
precision?: number;
limits?: {
amount?: MinMax;
withdraw?: MinMax;
deposit?: MinMax;
};
networks?: Dictionary<CurrencyNetwork>;
info: any;
}
interface CurrencyNetwork {
id: string;
network: string;
name?: string;
active: boolean;
deposit?: boolean;
withdraw?: boolean;
fee?: number;
precision?: number;
limits?: {
amount?: MinMax;
withdraw?: MinMax;
deposit?: MinMax;
};
info: any;
}Usage Examples:
const exchange = new ccxt.binance();
// Fetch all currencies
const currencies = await exchange.fetchCurrencies();
const btc = currencies['BTC'];
console.log(`${btc.name} (${btc.code})`);
console.log(`Deposit enabled: ${btc.deposit}`);
console.log(`Withdraw fee: ${btc.fee}`);
// Check currency networks
if (btc.networks) {
Object.values(btc.networks).forEach(network => {
console.log(`Network: ${network.name}, Fee: ${network.fee}`);
});
}Fetch trading fee structure for the exchange.
/**
* Fetch trading fees structure
*/
fetchTradingFees(params?: object): Promise<TradingFees>;
interface TradingFees {
info: any;
trading: {
tierBased: boolean;
percentage: boolean;
taker: number;
maker: number;
tiers?: {
taker: number[][];
maker: number[][];
};
};
funding: {
tierBased: boolean;
percentage: boolean;
withdraw: Dictionary<number>;
deposit: Dictionary<number>;
};
}Usage Examples:
const exchange = new ccxt.binance();
// Fetch trading fees
const fees = await exchange.fetchTradingFees();
console.log(`Maker fee: ${fees.trading.maker * 100}%`);
console.log(`Taker fee: ${fees.trading.taker * 100}%`);
console.log(`Tier-based: ${fees.trading.tierBased}`);
// Withdrawal fees
console.log('Withdrawal fees:');
Object.entries(fees.funding.withdraw).forEach(([currency, fee]) => {
console.log(` ${currency}: ${fee}`);
});Fetch funding rates for perpetual swap contracts.
/**
* Fetch funding rate for a specific symbol
*/
fetchFundingRate(symbol: string, params?: object): Promise<FundingRate>;
/**
* Fetch funding rates for multiple symbols
*/
fetchFundingRates(symbols?: string[], params?: object): Promise<Dictionary<FundingRate>>;
/**
* Fetch historical funding rates
*/
fetchFundingRateHistory(
symbol: string,
since?: number,
limit?: number,
params?: object
): Promise<FundingRate[]>;
interface FundingRate {
info: any;
symbol: string;
markPrice?: number;
indexPrice?: number;
interestRate?: number;
estimatedSettlePrice?: number;
timestamp: number;
datetime: string;
fundingRate: number;
fundingTimestamp?: number;
fundingDatetime?: string;
nextFundingRate?: number;
nextFundingTimestamp?: number;
nextFundingDatetime?: string;
}Usage Examples:
const exchange = new ccxt.binance();
await exchange.loadMarkets();
// Current funding rate
const fundingRate = await exchange.fetchFundingRate('BTC/USDT:USDT');
console.log(`Current funding rate: ${fundingRate.fundingRate * 100}%`);
console.log(`Next funding: ${fundingRate.nextFundingDatetime}`);
// All funding rates
const allRates = await exchange.fetchFundingRates();
Object.values(allRates).forEach(rate => {
console.log(`${rate.symbol}: ${rate.fundingRate * 100}%`);
});
// Historical funding rates
const history = await exchange.fetchFundingRateHistory('BTC/USDT:USDT', undefined, 10);
history.forEach(rate => {
console.log(`${rate.datetime}: ${rate.fundingRate * 100}%`);
});