Skip to content

REST API Usage

Igor Sazonov edited this page Jul 12, 2026 · 1 revision

The coinglass-php SDK organizes the Coinglass REST API into six logical resource groups. You access each group via a dedicated method on the CoinGlassClient instance (or the CoinGlass facade in Laravel). All methods handle authentication, query parameter serialization, and response hydration automatically.

Quick Start

The following example demonstrates fetching data from several resource groups in a single script:

use Tigusigalpa\CoinGlass\CoinGlassClient;

$client = CoinGlassClient::make('YOUR_API_KEY');

// Futures: Open Interest OHLC history
$oi = $client->futures()->openInterestOhlcHistory('BTC', '1d', 30);
foreach ($oi as $point) {
    echo "{$point->t}: \${$point->openInterestUsd}\n";
}

// Spot: Coin markets
$markets = $client->spot()->coinsMarkets();

// ETF: Bitcoin flow history
$flows = $client->etf()->bitcoinFlowHistory('1w', 24);

// Indicators: Fear & Greed index
$fearGreed = $client->indicators()->fearGreedHistory(30);

Futures Resource

Access via $client->futures(). This resource group covers the derivatives market, including open interest, funding rates, liquidations, long/short ratios, and orderbook data.

$futures = $client->futures();

// Open Interest
$oi        = $futures->openInterestOhlcHistory('BTC', '1d', 30);
$aggregated = $futures->openInterestAggregatedHistory('BTC', '4h');
$byExchange = $futures->openInterestExchangeList('BTC', '1h');

// Funding Rates
$frHistory   = $futures->fundingRateOhlcHistory('BTC', '8h');
$frByExchange = $futures->fundingRateExchangeList('BTC');
$arbitrage   = $futures->fundingRateArbitrage();

// Liquidations
$liq    = $futures->liquidationHistory('BTC', 'BTCUSDT', '1h');
$aggLiq = $futures->liquidationAggregatedHistory('BTC', '1h');
$heatmap = $futures->liquidationHeatmap('1', 'BTC', '12h');

// Long/Short Ratios
$lsRatio = $futures->longShortAccountRatioHistory('BTC', '1d');
$topLs   = $futures->topLongShortAccountRatio('BTC', '1d', 30, 'Binance');

// Orderbook
$ob          = $futures->orderbookHistory('BTC', 'Binance', '1h');
$largeOrders = $futures->orderbookLargeOrders('BTC', 'Binance');
Method HTTP Endpoint
supportedCoins() GET /futures/supported-coins
supportedExchangePairs(?exchange) GET /api/futures/supported-exchange-pairs
pairsMarkets(?symbol, ?exchange, ?limit) GET /api/futures/pairs-markets
coinsMarkets(?symbol, ?limit) GET /api/futures/coins-markets
priceChangeList() GET /futures/price-change-list
priceOhlcHistory(symbol, interval, ?limit, ?startTime, ?endTime) GET /api/price/ohlc-history
openInterestOhlcHistory(symbol, interval, ?limit, ?startTime, ?endTime) GET /api/futures/openInterest/ohlc-history
openInterestAggregatedHistory(symbol, interval, ?limit, ?startTime, ?endTime) GET /api/futures/openInterest/ohlc-aggregated-history
openInterestExchangeList(symbol, interval, ?limit, ?exchange) GET /api/futures/openInterest/exchange-list
fundingRateOhlcHistory(symbol, interval, ?limit, ?startTime, ?endTime) GET /api/futures/fundingRate/ohlc-history
fundingRateOiWeighted(symbol, interval, ?limit) GET /api/futures/fundingRate/oi-weight-ohlc-history
fundingRateExchangeList(symbol, ?interval, ?limit) GET /api/futures/fundingRate/exchange-list
fundingRateArbitrage(?symbol, ?limit) GET /api/futures/fundingRate/arbitrage
longShortAccountRatioHistory(symbol, interval, ?limit, ?exchange) GET /api/futures/global-long-short-account-ratio/history
topLongShortAccountRatio(symbol, interval, ?limit, ?exchange) GET /api/futures/top-long-short-account-ratio/history
liquidationHistory(symbol, pair, interval, ?limit) GET /api/futures/liquidation/history
liquidationAggregatedHistory(symbol, interval, ?limit) GET /api/futures/liquidation/aggregated-history
liquidationCoinList(?symbol, ?limit) GET /api/futures/liquidation/coin-list
liquidationHeatmap(model, symbol, interval, ?limit) GET /api/futures/liquidation/heatmap/model{1,2,3}
liquidationMap(symbol, pair, interval, ?limit) GET /api/futures/liquidation/map
orderbookHistory(symbol, exchange, interval, ?limit) GET /api/futures/orderbook/history
orderbookLargeOrders(symbol, exchange, ?limit) GET /api/futures/orderbook/large-limit-order
takerBuySellHistory(symbol, exchange, interval, ?limit) GET /api/futures/taker-buy-sell-volume/history
whaleBuySellHistory(?symbol, ?limit) GET /api/hyperliquid/whale-alert

Spot Resource

Access via $client->spot(). This resource group covers spot market data, including coin and pair markets, price history, orderbooks, and taker volume.

$spot = $client->spot();

$coins     = $spot->supportedCoins();
$markets   = $spot->coinsMarkets('BTC');
$orderbook = $spot->orderbookHistory('BTCUSDT', 'Binance', '1h');
$takerVol  = $spot->takerBuySellHistory('BTC', 'Binance', '1d');
Method HTTP Endpoint
supportedCoins() GET /api/spot/supported-coins
coinsMarkets(?symbol, ?limit) GET /api/spot/coins-markets
pairsMarkets(?symbol, ?exchange, ?limit) GET /api/spot/pairs-markets
priceHistory(symbol, interval, ?limit, ?startTime, ?endTime) GET /api/spot/price/history
orderbookHistory(symbol, exchange, interval, ?limit) GET /api/spot/orderbook/history
takerBuySellHistory(symbol, exchange, interval, ?limit) GET /api/spot/taker-buy-sell-volume/history

Options Resource

Access via $client->options(). This resource group covers the options market, including max pain, open interest, and volume history.

$options = $client->options();

$maxPain   = $options->maxPain('BTC');
$info      = $options->info('BTC');
$oiHistory = $options->exchangeOiHistory('1d', 30);
$volHistory = $options->exchangeVolHistory('1d', 30);
Method HTTP Endpoint
maxPain(underlying, ?expiry) GET /api/option/max-pain
info(underlying, ?expiry) GET /api/option/info
exchangeOiHistory(interval, ?limit) GET /api/option/exchange-oi-history
exchangeVolHistory(interval, ?limit) GET /api/option/exchange-vol-history

ETF Resource

Access via $client->etf(). This resource group covers Bitcoin and Ethereum ETF flows, net assets, and Grayscale holdings.

$etf = $client->etf();

$btcList   = $etf->bitcoinList();
$btcFlows  = $etf->bitcoinFlowHistory('1w', 24);
$btcAssets = $etf->bitcoinNetAssetsHistory('1d');
$ethFlows  = $etf->ethereumFlowHistory('1d');
$grayscale = $etf->grayscaleHoldings();
Method HTTP Endpoint
bitcoinList() GET /api/etf/bitcoin/list
bitcoinFlowHistory(interval, ?limit) GET /api/etf/bitcoin/flow-history
bitcoinNetAssetsHistory(interval, ?limit) GET /api/etf/bitcoin/net-assets/history
ethereumList() GET /api/etf/ethereum/list
ethereumFlowHistory(interval, ?limit) GET /api/etf/ethereum/flow-history
grayscaleHoldings() GET /api/grayscale/holdings-list

On-Chain Resource

Access via $client->onChain(). This resource group covers exchange asset balances and on-chain transfer data.

$onChain = $client->onChain();

$assets    = $onChain->exchangeAssets();
$balances  = $onChain->exchangeBalanceList('BTC', 'Binance');
$transfers = $onChain->exchangeOnChainTransfers('BTC', 50);
Method HTTP Endpoint
exchangeAssets() GET /api/exchange/assets
exchangeBalanceList(?symbol, ?exchange) GET /api/exchange/balance/list
exchangeOnChainTransfers(?symbol, ?limit) GET /api/exchange/chain/tx/list

Indicators Resource

Access via $client->indicators(). This resource group covers market sentiment and analytical indicators.

$indicators = $client->indicators();

$fearGreed = $indicators->fearGreedHistory(30);
$rsi       = $indicators->rsiList('BTC', '1d');
$basis     = $indicators->basisHistory('BTC', '1d');
$premium   = $indicators->coinbasePremiumIndex(30);
$rainbow   = $indicators->bitcoinRainbowChart();
$s2f       = $indicators->stockToFlow();
$stablecap = $indicators->stablecoinMarketCap(30);
Method HTTP Endpoint
fearGreedHistory(?limit) GET /api/index/fear-greed-history
rsiList(?symbol, ?interval, ?limit) GET /api/futures/rsi/list
basisHistory(symbol, interval, ?limit) GET /api/futures/basis/history
coinbasePremiumIndex(?limit) GET /api/coinbase-premium-index
bitcoinRainbowChart() GET /api/index/bitcoin/rainbow-chart
stockToFlow() GET /api/index/stock-flow
stablecoinMarketCap(?limit) GET /api/index/stableCoin-marketCap-history

Raw Requests

If you need to bypass DTO hydration and receive the raw decoded array from the API, call the request() method on the client directly:

$rawData = $client->request('/api/futures/openInterest/ohlc-history', [
    'symbol'   => 'BTC',
    'interval' => '1d',
    'limit'    => 30,
]);

This returns the decoded data field from the Coinglass JSON envelope as a plain PHP array.


Next: WebSocket API Usage

Clone this wiki locally