PHPackages                             baconfy/exchanges - 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. baconfy/exchanges

ActiveLibrary

baconfy/exchanges
=================

v0.2.0(today)02↑2900%MITPHPPHP ^8.4

Since Jul 31Pushed todayCompare

[ Source](https://github.com/baconfy/exchanges)[ Packagist](https://packagist.org/packages/baconfy/exchanges)[ RSS](/packages/baconfy-exchanges/feed)WikiDiscussions main Synced today

READMEChangelogDependencies (8)Versions (7)Used By (0)

baconfy/exchanges
=================

[](#baconfyexchanges)

Framework-agnostic Composer package for connecting to cryptocurrency exchanges. A single `Exchange` contract lets consumers fetch market data across multiple exchanges (Bybit, Binance, OKX, ...), where each exchange is an interchangeable driver — consumers program against the contract, never against a specific exchange.

**v0 scope: `klines()` only** (public candlestick data, no authentication). Balance, positions and orders come in later versions.

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

[](#requirements)

- PHP ^8.4
- A [PSR-18](https://www.php-fig.org/psr/psr-18/) HTTP client and a [PSR-17](https://www.php-fig.org/psr/psr-17/) request factory (e.g. `guzzlehttp/guzzle`)

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

[](#installation)

```
composer require baconfy/exchanges
```

The package requires only PSR interfaces — bring your own PSR-18/PSR-17 implementation:

```
composer require guzzlehttp/guzzle
```

Usage
-----

[](#usage)

```
use Baconfy\Exchanges\ExchangeManager;
use Baconfy\Exchanges\Enums\MarketType;
use Baconfy\Exchanges\Enums\Timeframe;
use GuzzleHttp\Client;
use GuzzleHttp\Psr7\HttpFactory;

$manager = new ExchangeManager(new Client(), new HttpFactory());

$candles = $manager->make('bybit', MarketType::Perpetual)->klines('BTCUSDT', Timeframe::M5, 100);

foreach ($candles as $candle) {
    // oldest to newest, every OHLCV field is an exact Brick\Math\BigDecimal
    echo "{$candle->openTime->format('c')}: {$candle->close}\n";
}
```

### Supported timeframes

[](#supported-timeframes)

`Timeframe::M1`, `M5`, `M15`, `M30`, `H1`, `H4`, `D1`, `W1` — each driver translates these to its own dialect (e.g. Bybit's `interval=240` for `H4`).

### Error handling

[](#error-handling)

Every failure the package throws implements `Baconfy\Exchanges\Exceptions\ExchangeException`, so you can catch broadly or narrowly:

```
use Baconfy\Exchanges\Exceptions\ApiException;
use Baconfy\Exchanges\Exceptions\ExchangeException;
use Baconfy\Exchanges\Exceptions\TransportException;

try {
    $manager->make('bybit', MarketType::Perpetual)->klines('BTCUSDT', Timeframe::M5);
} catch (ApiException $e) {
    // the exchange responded with an error: $e->retCode / $e->retMsg
} catch (TransportException $e) {
    // network failure, HTTP error status, or invalid JSON
} catch (ExchangeException $e) {
    // any other package failure (unknown driver, wrong credentials type, ...)
}
```

### Registering another driver

[](#registering-another-driver)

```
$manager->register('binance', BinanceDriver::class);
$manager->available(); // ['bybit', 'binance']
```

Every driver constructor follows the same shape — `(ClientInterface $http, RequestFactoryInterface $requests, MarketType $market, ?Credentials $credentials = null)` — so `ExchangeManager::make()` can build any of them generically.

Laravel
-------

[](#laravel)

The package ships an optional `ExchangesServiceProvider`, auto-discovered via Composer. It registers `ExchangeManager` as a container singleton, wired to whatever PSR-18/PSR-17 implementations your app has bound — it does not bind `Exchange::class` itself, since each connection may use a different driver and credentials:

```
$manager = app(\Baconfy\Exchanges\ExchangeManager::class);
$exchange = $manager->make($connection->driver, MarketType::Perpetual, $credentials);
```

`illuminate/support` is a `suggest`, never a hard dependency — the core works in a plain PHP script with no framework at all.

Testing
-------

[](#testing)

```
composer install
vendor/bin/pest
```

No test hits the network: HTTP is mocked at the PSR-18 boundary, and Bybit fixtures under `tests/Fixtures/` are real API responses, versioned deliberately.

Architecture
------------

[](#architecture)

Design decisions, invariants and the full build rationale live in [`.claude/ARCHITECTURE.md`](.claude/ARCHITECTURE.md) — the source of truth for this package.

###  Health Score

40

—

FairBetter than 86% of packages

Maintenance100

Actively maintained with recent releases

Popularity3

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

6

Last Release

0d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/7077461?v=4)[Renato Dehnhardt](/maintainers/rdehnhardt)[@rdehnhardt](https://github.com/rdehnhardt)

---

Top Contributors

[![rdehnhardt](https://avatars.githubusercontent.com/u/7077461?v=4)](https://github.com/rdehnhardt "rdehnhardt (17 commits)")

###  Code Quality

TestsPest

### Embed Badge

![Health badge](/badges/baconfy-exchanges/health.svg)

```
[![Health](https://phpackages.com/badges/baconfy-exchanges/health.svg)](https://phpackages.com/packages/baconfy-exchanges)
```

###  Alternatives

[flow-php/flow

PHP ETL - Extract Transform Load - Data processing framework

86337.5k](/packages/flow-php-flow)[tempest/framework

The PHP framework that gets out of your way.

2.3k37.6k18](/packages/tempest-framework)[guzzlehttp/psr7

PSR-7 message implementation that also provides common utility methods

8.0k1.1B4.3k](/packages/guzzlehttp-psr7)[cakephp/cakephp

The CakePHP framework

8.9k20.0M1.8k](/packages/cakephp-cakephp)[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.

36826.2k2](/packages/telnyx-telnyx-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)

PHPackages © 2026

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