PHPackages                             bazaarnexus/php-sdk - 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. bazaarnexus/php-sdk

ActiveLibrary[API Development](/categories/api)

bazaarnexus/php-sdk
===================

Official BazaarNexus PHP SDK for Accounts and Customers APIs.

v1.0.0(7mo ago)01MITPHPPHP &gt;=8.1

Since Sep 20Pushed 7mo agoCompare

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

READMEChangelog (1)Dependencies (2)Versions (2)Used By (0)

BazaarNexus PHP SDK
===================

[](#bazaarnexus-php-sdk)

A lightweight PHP SDK for accessing the BazaarNexus API using **Ed25519 key signatures**.
This SDK unifies both **merchant (account)** and **customer** authentication flows.

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

[](#requirements)

- PHP 8.1+
- [libsodium extension](https://www.php.net/manual/en/book.sodium.php) (built-in since PHP 7.2)
- [guzzlehttp/guzzle](https://github.com/guzzle/guzzle) ^7.0
- Composer for dependency management

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

[](#installation)

composer require bazaarnexus/php-sdk

Authentication Flow
-------------------

[](#authentication-flow)

Each API request is signed with:

- bazaarnexus-apikey – your API key (identifier)
- bazaarnexus-authorize – the auth mode (account or customer)
- bazaarnexus-nonce – millisecond timestamp (unique per request)
- bazaarnexus-signature – Ed25519 signature over:

authorize + "\\n" + route + "\\n" + payload + "\\n" + nonce

The backend verifies the signature using the public key tied to your API key.

Usage
-----

[](#usage)

### Merchant (Account) Request

[](#merchant-account-request)

use BazaarNexus\\ClientAPI;

$apiKey = "MERCHANT\_API\_KEY"; $privateKey = "MERCHANT\_PRIVATE\_KEY";

$client = new ClientAPI($apiKey, $privateKey, 'account'); $client-&gt;setEndPoint('');

try { $response = $client-&gt;sendRequest('orders/list', \[ 'status' =&gt; 'pending', 'limit' =&gt; 10, \]);

```
if ($client->isSuccess()) {
    print_r($client->getData());
} else {
    echo "Error: " . $client->getError();
}

```

} catch (Exception $e) { echo "Exception: " . $e-&gt;getMessage(); }

### Customer Request

[](#customer-request)

use BazaarNexus\\ClientAPI;

$apiKey = "CUSTOMER\_API\_KEY"; $privateKey = "CUSTOMER\_PRIVATE\_KEY";

$client = new ClientAPI($apiKey, $privateKey, 'customer'); $client-&gt;setEndPoint('');

try { $response = $client-&gt;sendRequest('cart/view'); if ($client-&gt;isSuccess()) { print\_r($client-&gt;getData()); } else { echo "Error: " . $client-&gt;getError(); } } catch (Exception $e) { echo "Exception: " . $e-&gt;getMessage(); }

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

[](#error-handling)

$response = $client-&gt;getLastResponse(); if (!$client-&gt;isSuccess()) { echo "Error: " . $client-&gt;getError(); }

Development Notes
-----------------

[](#development-notes)

- `UnifiedAPI` handles signing, HTTP client, response parsing.
- `ClientAPI` is a thin wrapper (for both merchants &amp; customers).
- Extendable for other API roles in the future.

Running Tests
-------------

[](#running-tests)

The SDK includes PHPUnit tests under the `tests/` directory.

### Install PHPUnit

[](#install-phpunit)

If not already installed:

```
composer require --dev phpunit/phpunit ^10

```

### Run Tests

[](#run-tests)

From the project root:

```
./vendor/bin/phpunit --bootstrap vendor/autoload.php tests

```

### Test Coverage

[](#test-coverage)

- **testSetEndPointNormalization**
    Ensures `setEndPoint()` strips query strings, fragments, and file extensions correctly.
- **testInvalidPrivateKeyThrowsException**
    Verifies that an invalid key format raises an `Exception`.
- **testSignAndRequestSimulation**
    Uses reflection to test the private `signMessage()` method to confirm signatures are generated correctly with Ed25519.
- **testSendRequestWithoutEndpointThrowsException**
    Confirms that `sendRequest()` cannot run unless `setEndPoint()` has been called.

### Notes

[](#notes)

- The tests **mock key generation** using libsodium’s `sodium_crypto_sign_keypair()` so no real API keys are needed.
- The actual HTTP request is **not executed**; instead, we test signing and endpoint validation logic.
- Extend these tests with integration tests once a live BazaarNexus API endpoint is available.

License
-------

[](#license)

MIT License

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance62

Regular maintenance activity

Popularity1

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity44

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

Unknown

Total

1

Last Release

239d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/486aa71294653de784612764439836a7b7b79c493e902996d2aadc538341865f?d=identicon)[BazaarNexus](/maintainers/BazaarNexus)

---

Top Contributors

[![BazaarNexus](https://avatars.githubusercontent.com/u/193024704?v=4)](https://github.com/BazaarNexus "BazaarNexus (3 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/bazaarnexus-php-sdk/health.svg)

```
[![Health](https://phpackages.com/badges/bazaarnexus-php-sdk/health.svg)](https://phpackages.com/packages/bazaarnexus-php-sdk)
```

###  Alternatives

[tencentcloud/tencentcloud-sdk-php

TencentCloudApi php sdk

3731.2M42](/packages/tencentcloud-tencentcloud-sdk-php)[convertkit/convertkitapi

Kit PHP SDK for the Kit API

2167.1k1](/packages/convertkit-convertkitapi)[mapado/rest-client-sdk

Rest Client SDK for hydra API

1125.9k2](/packages/mapado-rest-client-sdk)

PHPackages © 2026

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