Release v1.0.0 — First Stable Release
Tag: v1.0.0
Date: January 15, 2025
License: MIT
Requires: PHP 8.1+, ext-curl, ext-json
The first stable release of glassnode-php — an unofficial, framework-agnostic PHP SDK for the Glassnode Basic API, with a first-class Laravel bridge.
This release ships the complete documented metric surface: 25 typed category resources, a generic metric API for any present or future path, runtime metadata discovery, automatic 429 retry handling, a rich exception hierarchy, and immutable configuration. It works in plain PHP out of the box and auto-discovers in Laravel 10 through 13.
Highlights
Three Layers of API
- Transport & config —
GlassnodeClientwith a zero-dependency cURL transport (default) or any PSR-18 compatible client (Guzzle, Symfony HTTP Client, etc.).GlassnodeConfigis immutable, withfromArray()andfromEnv()factories. - Metadata & generic —
MetadataResourcefor runtime discovery of assets, metrics, and parameters;GlassnodeClient::get()for any metric path, present or future. - Ergonomic category resources — 25 typed resource classes mapping 1:1 to Glassnode's endpoint categories.
25 Category Resources
Addresses, Bridges, Blockchain, Breakdowns, DeFi, Derivatives, Distribution, Entities, ETH 2.0, Fees, Global, Indicators, Institutions, Lightning, Macro, Market, Mempool, Mining, Options, Point-In-Time, Protocols, Signals, Supply, Transactions, Treasuries — plus MetadataResource and UserResource.
Authentication
- Header mode (
X-Api-Key) by default — the key never appears in URLs or logs - Query-string mode (
api_key) opt-in viaGlassnodeConfig::AUTH_MODE_QUERYfor environments where headers aren't supported
Retry & Rate-Limit Awareness
- Automatic retry on HTTP 429,
GETrequests only - Honors the
x-rate-limit-resetheader when present; falls back to exponential backoff otherwise - Never retries 400, 401, or 404 — client errors that won't resolve by retrying
- Configurable via
retryAttempts(default: 3) andretryDelay(default: 1.0s)
Exception Hierarchy
A typed, catchable hierarchy so you can branch on errors without string matching:
GlassnodeException (base)
├── BadRequestException (HTTP 400)
├── UnauthorizedException (HTTP 401)
├── NotFoundException (HTTP 404)
├── RateLimitException (HTTP 429, after retries)
├── ConfigurationException (invalid config)
└── TransportException (network/HTTP errors)
Each exception carries the HTTP status code, response body, and (for RateLimitException) the rateLimitReset value.
Laravel Bridge
- Auto-discovered service provider and
Glassnodefacade — no manual registration - Publishable config file (
php artisan vendor:publish --tag=glassnode-config) - Dependency-injectable
GlassnodeClientfor controllers and services - No network requests at boot time — won't slow down app startup
PSR-18 Support
Bring your own HTTP client. Plug in Guzzle, Symfony HTTP Client, or any PSR-18 implementation alongside PSR-17 request/stream factories — useful for projects that already standardize on a particular client or need custom middleware (logging, circuit breakers, proxies).
Installation
composer require tigusigalpa/glassnode-phpNo hard dependencies beyond ext-curl and ext-json (both enabled by default in virtually every PHP installation). PSR-18/17 interfaces are required only if you opt out of the built-in cURL transport.
Quick Start
Plain PHP
use Tigusigalpa\Glassnode\GlassnodeClient;
use Tigusigalpa\Glassnode\GlassnodeConfig;
$client = new GlassnodeClient(new GlassnodeConfig(
apiKey: 'YOUR_API_KEY',
timeout: 15.0,
retryAttempts: 3,
));
$price = $client->market->price(['a' => 'BTC', 'i' => '24h']);
foreach ($price as $point) {
printf("BTC price at %d: $%.2f\n", $point['t'], $point['v']);
}Laravel
use Tigusigalpa\Glassnode\Laravel\Facades\Glassnode;
$price = Glassnode::market()->price(['a' => 'BTC', 'i' => '24h']);
$sopr = Glassnode::indicators()->sopr(['a' => 'BTC']);
$assets = Glassnode::metadata()->assets();Or via dependency injection:
use Tigusigalpa\Glassnode\GlassnodeClient;
class DashboardController extends Controller
{
public function index(GlassnodeClient $client)
{
$price = $client->market->price(['a' => 'BTC']);
$activeAddresses = $client->addresses->activeCount(['a' => 'BTC']);
return view('dashboard', [
'price' => $price,
'activeAddresses' => $activeAddresses,
]);
}
}What's Included
GlassnodeConfig— immutable configuration withfromArray()andfromEnv()factoriesGlassnodeClient— cURL transport (default) and PSR-18 client support- Header (
X-Api-Key) and query-string (api_key) authentication modes MetadataResource—assets(),metrics(),metric()endpointsUserResource—apiUsage()endpoint- 25 category resources with typed convenience methods
- Exception hierarchy:
GlassnodeException,ApiException,BadRequestException,UnauthorizedException,NotFoundException,RateLimitException,ConfigurationException,TransportException - Automatic retry on HTTP 429 with
x-rate-limit-resetheader support and exponential backoff - Laravel service provider, facade, and publishable configuration file
- Comprehensive test suite — 41 tests (37 unit + 4 feature) covering authentication, retries, errors, URL encoding, resource routing, and Laravel integration
docs/endpoint-coverage.mddocumenting all covered endpoints
Compatibility
- PHP 8.1+ (uses named arguments, readonly properties, enums)
- Laravel 10, 11, 12, 13 (auto-discovery, facade, config publishing)
- ext-curl and ext-json required (both enabled by default in standard PHP)
- PSR-18 client optional (for custom HTTP transports like Guzzle or Symfony HTTP Client)
Documentation
- README — full usage guide, configuration reference, and examples
- Endpoint coverage — every covered endpoint
- CHANGELOG — version history
- Glassnode Basic API docs — official API reference
Examples
- Basic usage — price, indicators, assets, API usage
- Laravel — facade and dependency injection in a controller
- Error handling — exception types and recovery strategies
Acknowledgements
This is an unofficial, community-built SDK. It is not affiliated with or endorsed by Glassnode. The official API documentation at docs.glassnode.com is the source of truth for endpoint behavior.
Links
- Repository: github.com/tigusigalpa/glassnode-php
- Packagist: packagist.org/packages/tigusigalpa/glassnode-php
- Author: Igor Sazonov — sovletig@gmail.com
- Issues: github.com/tigusigalpa/glassnode-php/issues
Full Changelog: CHANGELOG.md