PHPackages                             windy-network/client-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. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. windy-network/client-php

ActiveLibrary[Authentication &amp; Authorization](/categories/authentication)

windy-network/client-php
========================

Official PHP client SDK for the Windy Network API

v1.0.2(3mo ago)08MITPHPPHP ^8.1CI failing

Since Feb 8Pushed 3mo agoCompare

[ Source](https://github.com/windy-network/client-sdk-php)[ Packagist](https://packagist.org/packages/windy-network/client-php)[ Docs](https://github.com/windy-network/client-sdk-php)[ RSS](/packages/windy-network-client-php/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (3)Dependencies (11)Versions (4)Used By (0)

Windy Network PHP SDK
=====================

[](#windy-network-php-sdk)

Official PHP SDK for the [Windy Network](https://windy.network) API. Provides typed access to crypto, stocks, forex, options, and calendar market data with built-in authentication, retries, and real-time streaming.

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

[](#requirements)

- PHP 8.1+
- Composer

Installation
------------

[](#installation)

```
composer require windy-network/client-php
```

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

[](#quick-start)

```
use WindyNetwork\WindyClient;

$client = WindyClient::create('your-api-key');

// Crypto rates
$btc = $client->crypto->getRate('BTC', 'USD');
echo "BTC/USD: ${$btc->rate}";

// Stock quotes
$aapl = $client->stocks->getQuote('AAPL');
echo "AAPL: ${$aapl->price}";

// Forex rates
$eurusd = $client->forex->getRate('EUR', 'USD');
echo "EUR/USD: {$eurusd->rate}";
```

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

[](#configuration)

```
use WindyNetwork\Config;
use WindyNetwork\WindyClient;

$client = WindyClient::create(new Config(
    apiKey: 'your-api-key',
    baseUrl: 'https://api.windy.network',
    timeout: 30,
    retries: 3,
    debug: true,
));
```

Authentication
--------------

[](#authentication)

### API Key

[](#api-key)

```
$client = WindyClient::create('your-api-key');
```

### Basic Auth

[](#basic-auth)

```
use WindyNetwork\Config;
use WindyNetwork\Enums\AuthType;

$client = WindyClient::create(new Config(
    authType: AuthType::Basic,
    username: 'user',
    password: 'pass',
));
```

### OAuth 2.0

[](#oauth-20)

```
use WindyNetwork\Config;
use WindyNetwork\Enums\AuthType;

$client = WindyClient::create(new Config(
    authType: AuthType::OAuth,
    clientId: 'your-client-id',
    clientSecret: 'your-client-secret',
));

// Client credentials grant
$auth = $client->getAuthProvider();
$token = $auth->clientCredentialsGrant(['crypto:read', 'stock:read']);

// Authorization code grant with PKCE
use WindyNetwork\Auth\OAuthClient;

$codeVerifier = OAuthClient::generateCodeVerifier();
$codeChallenge = OAuthClient::generateCodeChallenge($codeVerifier);

$authUrl = $auth->getAuthorizationUrl([
    'state' => bin2hex(random_bytes(16)),
    'code_challenge' => $codeChallenge,
    'code_challenge_method' => 'S256',
]);

// After redirect:
$token = $auth->exchangeCode($code, $redirectUri, $codeVerifier);
```

API Endpoints
-------------

[](#api-endpoints)

### System

[](#system)

```
$health = $client->system->health();
$time = $client->system->time();
$version = $client->system->version();
```

### Crypto

[](#crypto)

```
use WindyNetwork\Enums\Timeframe;

// Rates
$rate = $client->crypto->getRate('BTC', 'USD');
$rates = $client->crypto->getRates('basecoin');

// OHLC candlestick data
$ohlc = $client->crypto->getOHLC('BTC', 'USD', Timeframe::H1, ['limit' => 24]);

// Technical indicators
$rsi = $client->crypto->getRSI('BTC', 'USD', Timeframe::D1, ['period' => 14]);
$sma = $client->crypto->getSMA('BTC', 'USD', Timeframe::D1, ['period' => 20]);
$ema = $client->crypto->getEMA('BTC', 'USD', Timeframe::D1, ['period' => 12]);
$macd = $client->crypto->getMACD('BTC', 'USD', Timeframe::D1);
$bb = $client->crypto->getBollingerBands('BTC', 'USD', Timeframe::D1);

// Tickers & orderbook
$ticker = $client->crypto->getTicker('binance', 'BTC', 'USD');
$orderbook = $client->crypto->getOrderbook('BTC', 'USD');

// Market data
$gainers = $client->crypto->getGainers();
$losers = $client->crypto->getLosers();
$summary = $client->crypto->getMarketSummary();

// Assets & exchanges
$assets = $client->crypto->getAssets();
$exchanges = $client->crypto->getExchanges();
```

### Stocks

[](#stocks)

```
$quote = $client->stocks->getQuote('AAPL');
$quotes = $client->stocks->getQuotes(['AAPL', 'GOOGL', 'MSFT']);
$ohlc = $client->stocks->getOHLC('AAPL', Timeframe::D1, ['limit' => 30]);
```

### Forex

[](#forex)

```
$rate = $client->forex->getRate('EUR', 'USD');
$rates = $client->forex->getRates();
$ohlc = $client->forex->getOHLC('EUR', 'USD', Timeframe::H1, ['limit' => 24]);
```

### Options

[](#options)

```
$chain = $client->options->getChain('AAPL', ['expiration' => '2025-01-17']);
```

### Calendar

[](#calendar)

```
$status = $client->calendar->getStatus();
$sessions = $client->calendar->getForexSessions();
$exchanges = $client->calendar->getExchanges();
$holidays = $client->calendar->getMarketHolidays(['market' => 'US']);
```

### User (Authenticated)

[](#user-authenticated)

```
// Alerts
$alerts = $client->user->getAlerts();
$alert = $client->user->createAlert([...]);
$client->user->deleteAlert($alertId);

// Watchlists
$watchlists = $client->user->getWatchlists();
$watchlist = $client->user->createWatchlist([...]);

// Portfolio
$portfolios = $client->user->getPortfolios();
$positions = $client->user->getPositions($portfolioId);
```

Real-Time Streaming
-------------------

[](#real-time-streaming)

### Server-Sent Events (SSE)

[](#server-sent-events-sse)

```
$sse = $client->sse();

$sse->on('connect', fn() => echo "Connected\n");
$sse->on('error', fn(\Throwable $e) => echo "Error: {$e->getMessage()}\n");

$channels = [
    'crypto:rate:basecoin:BTC:USD',
    'crypto:rate:basecoin:ETH:USD',
];

$sse->connect($channels, function ($message) {
    echo "[{$message->channel}] " . json_encode($message->data) . "\n";
});
```

### HTTP Polling

[](#http-polling)

```
$poller = $client->polling(['interval' => 5]);

$poller->connect(['crypto:rate:basecoin:BTC:USD'], function ($message) {
    echo json_encode($message->data) . "\n";
});
```

### WebSocket

[](#websocket)

Requires the optional `textalk/websocket` package:

```
composer require textalk/websocket
```

```
$ws = $client->websocket();

$ws->connect(['crypto:rate:basecoin:BTC:USD'], function ($message) {
    echo json_encode($message->data) . "\n";
});
```

Error Handling
--------------

[](#error-handling)

```
use WindyNetwork\Exceptions\AuthenticationException;
use WindyNetwork\Exceptions\RateLimitException;
use WindyNetwork\Exceptions\ValidationException;
use WindyNetwork\Exceptions\ApiException;
use WindyNetwork\Exceptions\WindyException;

try {
    $rate = $client->crypto->getRate('BTC', 'USD');
} catch (AuthenticationException $e) {
    // Invalid API key (401)
} catch (RateLimitException $e) {
    // Too many requests (429)
    sleep($e->retryAfter);
} catch (ValidationException $e) {
    // Bad request (400)
    $details = $e->details;
} catch (ApiException $e) {
    // Other HTTP errors
    echo "Status: {$e->statusCode}, Request ID: {$e->requestId}";
} catch (WindyException $e) {
    // SDK-level errors
}

// Check if an error is retryable
if (WindyException::isRetryable($e)) {
    // Retry the request
}
```

Rate Limiting
-------------

[](#rate-limiting)

Rate limit info is available after each request:

```
$rateLimit = $client->getHttpClient()->getRateLimit();
if ($rateLimit) {
    echo "Remaining: {$rateLimit->remaining}/{$rateLimit->limit}";
}
```

The SDK automatically retries on 429 responses with exponential backoff.

Laravel Integration
-------------------

[](#laravel-integration)

### Setup

[](#setup)

```
composer require windy-network/client-php
php artisan vendor:publish --tag=windy-config
```

Add to your `.env`:

```
WINDY_API_KEY=your-api-key

```

### Usage

[](#usage)

```
// Dependency injection
class CryptoController extends Controller
{
    public function __construct(
        private readonly WindyClient $windy,
    ) {}

    public function rate(string $base, string $quote)
    {
        return response()->json(
            $this->windy->crypto->getRate($base, $quote)
        );
    }
}

// Facade
use WindyNetwork\Laravel\WindyFacade as Windy;

$rate = Windy::crypto->getRate('BTC', 'USD');

// Helper
$client = app(\WindyNetwork\WindyClient::class);
```

Symfony Integration
-------------------

[](#symfony-integration)

### Configuration

[](#configuration-1)

```
# config/packages/windy.yaml
windy:
    api_key: '%env(WINDY_API_KEY)%'
    base_url: 'https://api.windy.network'
    timeout: 30
    retries: 3
```

### Usage

[](#usage-1)

```
class CryptoController extends AbstractController
{
    public function __construct(
        private readonly WindyClient $windy,
    ) {}

    #[Route('/rate/{base}/{quote}')]
    public function rate(string $base, string $quote): JsonResponse
    {
        $rate = $this->windy->crypto->getRate($base, $quote);
        return $this->json($rate);
    }
}
```

Testing
-------

[](#testing)

```
# Unit tests
vendor/bin/phpunit --testsuite=Unit

# Integration tests (requires API key)
WINDY_API_KEY=your-key vendor/bin/phpunit --testsuite=Integration

# Static analysis
vendor/bin/phpstan analyse

# Code style
vendor/bin/php-cs-fixer fix --dry-run
```

Examples
--------

[](#examples)

See the [examples/](examples/) directory:

- [basic-usage.php](examples/basic-usage.php) - API key setup, rates, OHLC, indicators
- [oauth-flow.php](examples/oauth-flow.php) - OAuth grants, PKCE, token management
- [streaming-sse.php](examples/streaming-sse.php) - Real-time SSE streaming
- [error-handling.php](examples/error-handling.php) - Exception patterns
- [laravel-example.php](examples/laravel-example.php) - Laravel DI, facade, config

License
-------

[](#license)

MIT

###  Health Score

36

—

LowBetter than 82% of packages

Maintenance81

Actively maintained with recent releases

Popularity4

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity45

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

Every ~0 days

Total

3

Last Release

99d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/afcb7ea859fbb0b6cf6c0a317d8e59e823f4aecaf91652bec67c3defa9101e69?d=identicon)[windy-network](/maintainers/windy-network)

---

Top Contributors

[![admin-windy-network](https://avatars.githubusercontent.com/u/242058878?v=4)](https://github.com/admin-windy-network "admin-windy-network (3 commits)")

---

Tags

apisymfonylaravelsdkoptionscryptooauthforexmarket datastockswindy-network

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/windy-network-client-php/health.svg)

```
[![Health](https://phpackages.com/badges/windy-network-client-php/health.svg)](https://phpackages.com/packages/windy-network-client-php)
```

###  Alternatives

[kreait/firebase-php

Firebase Admin SDK

2.4k39.7M72](/packages/kreait-firebase-php)[saloonphp/saloon

Build beautiful API integrations and SDKs with Saloon

2.4k9.6M468](/packages/saloonphp-saloon)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

245.2k](/packages/aedart-athenaeum)[bushlanov-dev/max-bot-api-client-php

Max Bot API Client library

281.6k](/packages/bushlanov-dev-max-bot-api-client-php)[surfoo/geocaching-php-sdk

Geocaching PHP SDK

143.4k1](/packages/surfoo-geocaching-php-sdk)

PHPackages © 2026

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