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

coinglass-php

Derivatives, ETF, and on-chain market intelligence for PHP & Laravel.

coinglass-php is a modern, framework-agnostic PHP SDK for the Coinglass API v4, with first-class Laravel 10–13 integration. Whether you are building a liquidation dashboard, tracking funding-rate arbitrage, or monitoring Bitcoin ETF flows, this library gives you clean, typed, and production-ready access to Coinglass's Futures, Spot, Options, ETF, On-Chain, and Indicator endpoints.

Why coinglass-php?

The Coinglass API v4 is a comprehensive source of institutional-grade crypto market data, covering derivatives, spot, options, ETF, and on-chain markets. coinglass-php wraps this API in a developer-friendly PHP package that handles the low-level concerns — authentication, JSON envelope unwrapping, retry logic, and response hydration — so that you can focus on building your application.

The SDK is designed around several core principles. It provides complete API coverage, exposing every major Coinglass endpoint through a fluent, resource-based interface. It includes a real-time WebSocket client built directly on PHP streams, so you can stream liquidation orders, spot and futures trades, and ticker snapshots without adding any extra Composer dependency. The library is framework-agnostic, working equally well in a standalone PHP script or a full Laravel application. It uses PSR-18 standard interfaces for its HTTP client, defaulting to Guzzle but allowing you to swap in any compatible client. It provides automatic retry with exponential backoff on HTTP 429 responses, and it hydrates every response into typed DTOs and collections for clean, predictable data access.

Requirements

Requirement Version
PHP 8.1+
Laravel (optional) 10.x, 11.x, 12.x, 13.x
HTTP client Guzzle ^7.4 (default, PSR-18 swappable)
WebSocket API ext-openssl (for wss://; no extra Composer package needed)
Coinglass API key Required — obtain one at coinglass.com/pricing

Architecture Overview

The library is organized into a small set of focused classes. The CoinGlassClient is the central entry point, holding the configuration and the HTTP client. It exposes six resource groups — futures(), spot(), options(), etf(), onChain(), and indicators() — each of which is a dedicated class containing the methods for that domain. A separate CoinGlassWebSocketClient handles real-time streaming. All responses are hydrated through AbstractResource into either a CoinGlassDto (single record) or a CoinGlassCollection (list of records).

Wiki Navigation

Page Description
Installation and Configuration How to install via Composer and configure the client for standalone PHP or Laravel.
REST API Usage A guide to all six resource groups: Futures, Spot, Options, ETF, On-Chain, and Indicators.
WebSocket API Usage How to connect, subscribe to channels, and stream real-time data.
Responses and DTOs How the SDK hydrates API responses into CoinGlassDto and CoinGlassCollection.
Error Handling The exception hierarchy and the automatic retry behavior for rate limits.
Full API Reference Complete method signatures for all resource groups and the WebSocket client.

License

This project is released under the MIT License. See the LICENSE file in the repository for details. The library was created by Igor Sazonov.

Clone this wiki locally