PHPackages                             tigusigalpa/coinglass-php - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. tigusigalpa/coinglass-php

ActiveLibrary[API Development](/categories/api)

tigusigalpa/coinglass-php
=========================

A modern, framework-agnostic PHP SDK for the Coinglass API v4, with first-class Laravel 10, 11, 12 &amp; 13 integration.

v1.0.0(1mo ago)150MITPHPPHP ^8.1

Since Jul 12Pushed 1mo agoCompare

[ Source](https://github.com/tigusigalpa/coinglass-php)[ Packagist](https://packagist.org/packages/tigusigalpa/coinglass-php)[ Docs](https://github.com/tigusigalpa/coinglass-php)[ RSS](/packages/tigusigalpa-coinglass-php/feed)WikiDiscussions main Synced 1w ago

READMEChangelog (1)Dependencies (7)Versions (2)Used By (0)

coinglass-php
=============

[](#coinglass-php)

[![CoinGlass PHP SDK](https://camo.githubusercontent.com/c29dc82abd208cc7665f36a8cd16b30410879d86d4da64f317adb920ede84435/68747470733a2f2f692e706f7374696d672e63632f744a676b6768446e2f636f696e676c6173732d7068702d62616e6e65722e6a7067)](https://camo.githubusercontent.com/c29dc82abd208cc7665f36a8cd16b30410879d86d4da64f317adb920ede84435/68747470733a2f2f692e706f7374696d672e63632f744a676b6768446e2f636f696e676c6173732d7068702d62616e6e65722e6a7067)

> A PHP client for the Coinglass API v4, with first-class Laravel support.

`coinglass-php` is a framework-agnostic PHP SDK for the [Coinglass API v4](https://docs.coinglass.com/reference/getting-started-with-your-api). I put it together while building a liquidation dashboard and got tired of hand-rolling Guzzle calls and juggling raw arrays, so it wraps the Futures, Spot, Options, ETF, On-Chain, and Indicator endpoints — plus the real-time WebSocket streams — in a typed, PSR-18-friendly client that drops straight into Laravel if you need it, or works standalone if you don't.

[![PHP Version](https://camo.githubusercontent.com/bb300443d7f0b99cc32032f3a10588ffff510dbe28c019a03d78a3babac19199/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253345253344382e312d3737376262343f6c6f676f3d706870)](https://www.php.net/)[![Laravel](https://camo.githubusercontent.com/d3849144e6f363bf5e52838b5e1bb31f3b11ae4e9b62e2dcb7487c2e600ef4f1/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c61726176656c2d31302532302537432532303131253230253743253230313225323025374325323031332d6666326432303f6c6f676f3d6c61726176656c)](https://laravel.com/)[![License](https://camo.githubusercontent.com/7013272bd27ece47364536a221edb554cd69683b68a46fc0ee96881174c4214c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c75652e737667)](LICENSE)[![Tests](https://camo.githubusercontent.com/d940ad7f0752e2cbe0d63c50dcebf329078807390051c41fe63258f1b5c4e182/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f74657374732d70617373696e672d627269676874677265656e)](.)

Features
--------

[](#features)

- Covers all six endpoint groups: Futures, Spot, Options, ETF, On-Chain, and Indicators.
- Ships a real-time WebSocket client for liquidation orders, spot/futures trades, and futures ticker snapshots — no extra WebSocket library needed, it's built on plain PHP streams.
- Framework-agnostic: use it standalone in any PHP 8.1+ project, or drop it straight into Laravel.
- PSR-18 swappable HTTP client — Guzzle by default, bring your own if you'd rather.
- Retries rate-limited (429) requests with exponential backoff, honoring `Retry-After` when Coinglass sends one.
- Hydrates every payload into a `CoinGlassDto` or `CoinGlassCollection`, with the original raw payload always within reach.
- A small, purposeful exception hierarchy — `UnauthorizedException`, `NotFoundException`, `RateLimitException`, and a generic `ApiException` for everything else — instead of one catch-all.
- Laravel-ready out of the box: publishable config, a bound singleton client, dependency injection, and a `CoinGlass` facade.

Requirements
------------

[](#requirements)

RequirementVersionPHP8.1+Laravel (optional)10.x, 11.x, 12.x, 13.xHTTP clientGuzzle `^7.4` (default, PSR-18 swappable)WebSocket API`ext-openssl` (for `wss://`; no extra Composer package needed)Coinglass API key[Get one here](https://coinglass.com)Installation
------------

[](#installation)

```
composer require tigusigalpa/coinglass-php
```

### Local development path

[](#local-development-path)

Working against a local checkout? Point Composer at it with a path repository in your `composer.json`:

```
{
    "repositories": [
        {
            "type": "path",
            "url": "../packages/coinglass-php"
        }
    ]
}
```

Configuration
-------------

[](#configuration)

### Standalone

[](#standalone)

```
use Tigusigalpa\CoinGlass\CoinGlassClient;
use Tigusigalpa\CoinGlass\CoinGlassConfig;

// Simple initialization
$client = CoinGlassClient::make('YOUR_API_KEY');

// Full configuration
$config = new CoinGlassConfig(
    apiKey: 'YOUR_API_KEY',
    baseUrl: 'https://open-api-v4.coinglass.com',
    timeout: 15.0,
    retryAttempts: 3,
    retryDelay: 1.0,
);
$client = new CoinGlassClient($config);

// From environment variables (COINGLASS_API_KEY, COINGLASS_BASE_URL, ...)
$client = new CoinGlassClient(CoinGlassConfig::fromEnv());
```

### Laravel

[](#laravel)

Publish the config file (optional):

```
php artisan vendor:publish --tag=coinglass-config
```

```
COINGLASS_API_KEY=your-api-key
COINGLASS_BASE_URL=https://open-api-v4.coinglass.com
COINGLASS_TIMEOUT=15
COINGLASS_RETRY_ATTEMPTS=3
COINGLASS_RETRY_DELAY=1
```

Via the facade:

```
use Tigusigalpa\CoinGlass\Laravel\Facades\CoinGlass;

$oi = CoinGlass::futures()->openInterestOhlcHistory('BTC', '1d', 30);
```

Via dependency injection:

```
use Tigusigalpa\CoinGlass\CoinGlassClient;

class MarketController
{
    public function __construct(private readonly CoinGlassClient $coinGlass) {}

    public function index()
    {
        return $this->coinGlass->etf()->bitcoinFlowHistory('1w', 24);
    }
}
```

Quick Start
-----------

[](#quick-start)

```
use Tigusigalpa\CoinGlass\CoinGlassClient;

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

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

$funding = $client->futures()->fundingRateExchangeList('BTC');
$liq = $client->futures()->liquidationHistory('BTC', 'BTCUSDT', '1h');

// Spot
$markets = $client->spot()->coinsMarkets();
$orderbook = $client->spot()->orderbookHistory('BTCUSDT', 'Binance', '1h');

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

// Indicators
$fearGreed = $client->indicators()->fearGreedHistory(30);
```

Whatever you call, you get back a `Tigusigalpa\CoinGlass\Dto\CoinGlassDto` for a single record or a `Tigusigalpa\CoinGlass\Collections\CoinGlassCollection` for a list. Reach for a field however feels natural — property syntax (`$dto->openInterestUsd`), array syntax (`$dto['openInterestUsd']`), or `$dto->get('openInterestUsd')` — and if you ever need the untouched payload, it's right there via `$dto->raw` / `$dto->toArray()`.

Full API Reference
------------------

[](#full-api-reference)

Every method maps to a single Coinglass endpoint and returns the hydrated `data` payload. Optional parameters are marked with `?` below.

### Futures — `$client->futures()`

[](#futures--client-futures)

MethodEndpoint`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 — `$client->spot()`

[](#spot--client-spot)

MethodEndpoint`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 — `$client->options()`

[](#options--client-options)

MethodEndpoint`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 — `$client->etf()`

[](#etf--client-etf)

MethodEndpoint`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 — `$client->onChain()`

[](#on-chain--client-onchain)

MethodEndpoint`exchangeAssets()``GET /api/exchange/assets``exchangeBalanceList(?symbol, ?exchange)``GET /api/exchange/balance/list``exchangeOnChainTransfers(?symbol, ?limit)``GET /api/exchange/chain/tx/list`### Indicators — `$client->indicators()`

[](#indicators--client-indicators)

MethodEndpoint`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`WebSocket API
-------------

[](#websocket-api)

The REST client covers historical data; for anything real-time — liquidation orders, spot and futures trades, futures ticker snapshots — there's a small WebSocket client too. It talks [Coinglass's WebSocket API](https://docs.coinglass.com/reference/ws-getting-started) directly over PHP streams (`stream_socket_client`), implementing just enough of the protocol to get the job done, so you don't need to pull in a separate WebSocket library.

```
use Tigusigalpa\CoinGlass\CoinGlassClient;
use Tigusigalpa\CoinGlass\WebSocket\Channels;
use Tigusigalpa\CoinGlass\WebSocket\Message;

$client = CoinGlassClient::make('YOUR_API_KEY');
$stream = $client->websocket()->connect();

$stream->subscribe(
    Channels::liquidationOrders(),
    Channels::futuresTicker('Binance', 'BTCUSDT'),
);

$stream->listen(function (Message $message) {
    if ($message->channel === Channels::liquidationOrders()) {
        foreach ($message->collection() as $order) {
            echo "{$order->exchange} {$order->symbol} liquidated \${$order->volume_usd}\n";
        }
    }
});
```

A single connection carries every subscription; `subscribe()`/`unsubscribe()` accept any number of channel names, and the `"ping"` heartbeat Coinglass expects every 20 seconds is sent automatically. `listen()` blocks forever, which fits a long-running CLI worker or queued job; if you need finer control (e.g. to integrate with an existing event loop), call `$stream->read($timeoutSeconds)` yourself to pull one message at a time.

### Channel helpers

[](#channel-helpers)

HelperChannelDocs`Channels::liquidationOrders()``liquidation_orders`[Liquidation Order](https://docs.coinglass.com/reference/ws-liquidation-order)`Channels::spotTrades($exchange, $symbol, $minVolumeUsd)``spot_trades@{exchange}_{symbol}@{minVolumeUsd}`[Spot Trade Order](https://docs.coinglass.com/reference/websocket_spot_trades)`Channels::futuresTrades($exchange, $symbol, $minVolumeUsd)``futures_trades@{exchange}_{symbol}@{minVolumeUsd}`[Futures Trade Order](https://docs.coinglass.com/reference/websocket_futures_trades)`Channels::futuresTicker($exchange, $symbol)``futures_ticker@{exchange}_{symbol}`[Futures Ticker Snapshot](https://docs.coinglass.com/reference/websocket_futures_ticker)Every message's `data` payload can be hydrated with `$message->collection()`, returning the same `CoinGlassCollection` of `CoinGlassDto` records used throughout the REST client — access fields with `$order->volume_usd`, `$order['volume_usd']`, or `$order->get('volume_usd')`.

### Laravel

[](#laravel-1)

```
use Tigusigalpa\CoinGlass\Laravel\Facades\CoinGlass;

$stream = CoinGlass::websocket()->connect();
```

Publish the config (`php artisan vendor:publish --tag=coinglass-config`) to override the WebSocket endpoint via `COINGLASS_WS_BASE_URL`, `COINGLASS_WS_CONNECT_TIMEOUT`, and `COINGLASS_WS_PING_INTERVAL`.

### Errors

[](#errors)

Connection, handshake, and read/write failures throw `Tigusigalpa\CoinGlass\Exceptions\WebSocketException` (a `CoinGlassException`), so it's caught by the same `catch (CoinGlassException $e)` you might already have.

Error handling
--------------

[](#error-handling)

Nothing fails silently. The common cases each get their own exception, so you can catch exactly what you care about and let the rest bubble up:

```
use Tigusigalpa\CoinGlass\Exceptions\ApiException;
use Tigusigalpa\CoinGlass\Exceptions\NotFoundException;
use Tigusigalpa\CoinGlass\Exceptions\RateLimitException;
use Tigusigalpa\CoinGlass\Exceptions\UnauthorizedException;

try {
    $oi = $client->futures()->openInterestOhlcHistory('BTC', '1d', 30);
} catch (UnauthorizedException $e) {
    // Invalid or missing API key
} catch (RateLimitException $e) {
    // Retries exhausted; $e->retryAfter holds the Retry-After value, if any
} catch (NotFoundException $e) {
    // Endpoint/resource not found
} catch (ApiException $e) {
    // Any other non-2xx response or non-zero envelope code
    // $e->statusCode, $e->apiCode, $e->responseBody are all available
}
```

Retry behavior
--------------

[](#retry-behavior)

Coinglass rate-limits aggressively on some plans, so on HTTP `429` the client reads the `Retry-After` header if present, or falls back to exponential backoff (`retryDelay * 2^attempt`), retrying up to `retryAttempts` times before giving up and throwing `RateLimitException`:

```
$config = new CoinGlassConfig(
    apiKey: 'YOUR_API_KEY',
    retryAttempts: 3,
    retryDelay: 1.0, // 1s, then 2s, then 4s
);
```

Testing
-------

[](#testing)

```
composer install
vendor/bin/phpunit
```

The suite leans on Guzzle's `MockHandler` for the HTTP-layer unit tests and Orchestra Testbench for the Laravel integration tests, so it runs without ever touching the real Coinglass API.

License
-------

[](#license)

MIT © [Igor Sazonov](https://github.com/tigusigalpa)

###  Health Score

38

—

LowBetter than 83% of packages

Maintenance90

Actively maintained with recent releases

Popularity8

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity42

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

49d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/2721390?v=4)[Igor Sazonov](/maintainers/tigusigalpa)[@tigusigalpa](https://github.com/tigusigalpa)

---

Top Contributors

[![tigusigalpa](https://avatars.githubusercontent.com/u/2721390?v=4)](https://github.com/tigusigalpa "tigusigalpa (2 commits)")

---

Tags

apibitcoinchainlinkcoinglasscoinglass-apilaravelnearprotocolphplaravelsdkcryptoapi clientfuturesderivativescoinglass

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/tigusigalpa-coinglass-php/health.svg)

```
[![Health](https://phpackages.com/badges/tigusigalpa-coinglass-php/health.svg)](https://phpackages.com/packages/tigusigalpa-coinglass-php)
```

###  Alternatives

[tempest/framework

The PHP framework that gets out of your way.

2.3k42.4k21](/packages/tempest-framework)[aws/aws-sdk-php

AWS SDK for PHP - Use Amazon Web Services in your PHP project

6.4k567.5M2.9k](/packages/aws-aws-sdk-php)[typo3/cms

TYPO3 CMS is a free open source Content Management Framework initially created by Kasper Skaarhoj and licensed under GNU/GPL.

1.2k1.9M122](/packages/typo3-cms)[flow-php/flow

PHP ETL - Extract Transform Load - Data processing framework

86538.6k](/packages/flow-php-flow)[typo3/cms-core

TYPO3 CMS Core

3714.0M5.9k](/packages/typo3-cms-core)[telnyx/telnyx-php

Official Telnyx PHP SDK — APIs for Voice, SMS, MMS, WhatsApp, Fax, SIP Trunking, Wireless IoT, Call Control, and more. Build global communications on Telnyx's private carrier-grade network.

36863.5k2](/packages/telnyx-telnyx-php)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
