Skip to content

Releases: tigusigalpa/coinglass-php

Release list

v1.0.0

Choose a tag to compare

@tigusigalpa tigusigalpa released this 12 Jul 19:28

coinglass-php v1.0.0

First stable release of coinglass-php — a framework-agnostic PHP SDK for the Coinglass API v4, with first-class Laravel 10–13 support.

Highlights

  • Full REST coverage across all six endpoint groups: Futures, Spot, Options, ETF, On-Chain, and Indicators.
  • Real-time WebSocket client for liquidation orders, spot/futures trades, and futures ticker snapshots — built on plain PHP streams, no extra WebSocket library required (only ext-openssl for wss://).
  • Typed responses — every payload is hydrated into a CoinGlassDto or CoinGlassCollection, with the original raw payload always available via $dto->raw / $dto->toArray().
  • Laravel-ready out of the box — publishable config, a bound singleton client, dependency injection, and a CoinGlass facade.

Features

REST client

  • Fluent, grouped API surface: $client->futures(), ->spot(), ->options(), ->etf(), ->onChain(), ->indicators().
  • PSR-18 swappable HTTP client — Guzzle by default, bring your own if you prefer.
  • Automatic retry on HTTP 429 with exponential backoff, honoring the Retry-After header when Coinglass sends one.
  • Flexible field access: property syntax ($dto->openInterestUsd), array syntax ($dto['openInterestUsd']), or $dto->get('openInterestUsd').
  • Configuration via constructor, CoinGlassConfig::fromEnv(), or Laravel config file.

WebSocket client

  • Single multiplexed connection with subscribe() / unsubscribe() for any number of channels.
  • Automatic "ping" heartbeat handling.
  • Both a blocking listen($callback) loop and a read($timeout) pull model for custom event loops.
  • Channel helpers: Channels::liquidationOrders(), spotTrades(), futuresTrades(), futuresTicker().
  • Messages hydrate into the same CoinGlassCollection / CoinGlassDto used by the REST client.

Error handling

  • A focused exception hierarchy — UnauthorizedException, NotFoundException, RateLimitException, WebSocketException, and a generic ApiException, all extending CoinGlassException.
  • ApiException exposes statusCode, apiCode, and responseBody; RateLimitException exposes retryAfter.

Requirements

  • PHP 8.1+
  • Laravel 10.x–13.x (optional)
  • Guzzle ^7.4 (default, PSR-18 swappable)
  • ext-openssl for WebSocket wss:// connections

Installation

composer require tigusigalpa/coinglass-php

Testing

Fully covered by unit tests using Guzzle's MockHandler and Orchestra Testbench — the suite runs without ever hitting the live Coinglass API.