PHPackages                             tigusigalpa/phemex-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. [API Development](/categories/api)
4. /
5. tigusigalpa/phemex-php

ActiveLibrary[API Development](/categories/api)

tigusigalpa/phemex-php
======================

A framework-agnostic PHP client for the Phemex cryptocurrency exchange API with first-class Laravel support.

v1.0.2(yesterday)00MITPHP ^8.1

Since Jul 19Compare

[ Source](https://github.com/tigusigalpa/phemex-php)[ Packagist](https://packagist.org/packages/tigusigalpa/phemex-php)[ Docs](https://github.com/tigusigalpa/phemex-php)[ RSS](/packages/tigusigalpa-phemex-php/feed)WikiDiscussions Synced today

READMEChangelog (2)Dependencies (5)Versions (3)Used By (0)

Phemex PHP
==========

[](#phemex-php)

[![Phemex PHP SDK](https://camo.githubusercontent.com/1949822a7a7f7314cf1131fb98cbf2627cb6ba2a4038ba82d0dac5f4541c869a/68747470733a2f2f692e706f7374696d672e63632f32535654367944672f7068656d65782d6170692d7068702e6a7067)](https://camo.githubusercontent.com/1949822a7a7f7314cf1131fb98cbf2627cb6ba2a4038ba82d0dac5f4541c869a/68747470733a2f2f692e706f7374696d672e63632f32535654367944672f7068656d65782d6170692d7068702e6a7067)

[![PHP Version](https://camo.githubusercontent.com/ef363a5a30025ffef1857918c40fa01e97f03929e5f87d12a14bf334a7de9220/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253545382e312d3838393242462e737667)](https://php.net)[![License](https://camo.githubusercontent.com/8bb50fd2278f18fc326bf71f6e88ca8f884f72f179d3e555e20ed30157190d0d/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d677265656e2e737667)](LICENSE)[![Latest Stable Version](https://camo.githubusercontent.com/8a8346aedf6dd0a64657ef7b9bb003eb8d4f3ff3660a38a16fe62f59d06c406d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f74696775736967616c70612f7068656d65782d7068702e737667)](https://packagist.org/packages/tigusigalpa/phemex-php)

> A typed PHP client for the [Phemex](https://phemex.com/) exchange API. Drop it into any PHP 8.1+ project, and if you're on Laravel 10–13 it just works — no extra setup.

I got tired of hand-rolling cURL calls, computing HMAC signatures, and bolting on retry logic every time I touched the Phemex API. So this library does all of that for you and hands back a clean, object-oriented interface. You write strategy; it handles the plumbing.

```
use Tigusigalpa\Phemex\PhemexClient;

$client = PhemexClient::create([
    'api_key' => getenv('PHEMEX_API_KEY'),
    'api_secret' => getenv('PHEMEX_API_SECRET'),
]);

$ticker = $client->market()->ticker24h('BTCUSDT');
print_r($ticker->result());
```

---

What's in the box
-----------------

[](#whats-in-the-box)

- **Runs anywhere.** The core is plain PHP 8.1+ built on PSR-18 — no framework required.
- **Laravel, out of the box.** Auto-discovered service provider, publishable config, and a `Phemex` facade.
- **Signing you don't think about.** Private endpoints get HMAC SHA256 signatures automatically, straight from Phemex's own algorithm.
- **Your HTTP client, your rules.** Guzzle ships by default, but swap in any PSR-18 implementation you like.
- **Responses that won't break.** Return values are DTOs that keep the raw payload around, so when Phemex adds a field, you can still reach it.
- **Retries handled for you.** Rate limits (HTTP 429) and flaky server errors are retried with exponential backoff.
- **Exceptions that make sense.** `AuthenticationException`, `RateLimitException`, `NotFoundException`, `ValidationException`, and `ApiException`.
- **Real-time when you need it.** Optional WebSocket streams via `ratchet/pawl`.

---

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

[](#installation)

```
composer require tigusigalpa/phemex-php
```

### Laravel

[](#laravel)

The service provider is auto-discovered, so there's nothing to register. Publish the config file whenever you want to tweak the defaults:

```
php artisan vendor:publish --provider="Tigusigalpa\Phemex\Laravel\PhemexServiceProvider"
```

Then set your environment variables:

```
PHEMEX_API_KEY=your_api_key
PHEMEX_API_SECRET=your_api_secret
```

---

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

[](#configuration)

After publishing, `config/phemex.php` contains:

```
return [
    'api_key'    => env('PHEMEX_API_KEY'),
    'api_secret' => env('PHEMEX_API_SECRET'),
    'base_uri'   => env('PHEMEX_BASE_URI', 'https://api.phemex.com'),
    'timeout'    => 30,
    'retries'    => 3,
    'retry_delay' => 1,
];
```

Prefer your own PSR-18 client — maybe with custom middleware, logging, or metrics? Just bind it in a service provider:

```
$this->app->bind(\Psr\Http\Client\ClientInterface::class, MyPsr18Client::class);
```

---

Quick start
-----------

[](#quick-start)

### Standalone PHP

[](#standalone-php)

```
