Skip to main content
The PHP SDK for Exchanger API v3 signs private requests with HMAC v2 and returns typed results with HTTP status and request identifiers.

Install the SDK

Use PHP 8.5 with the curl extension. The built-in Guzzle HTTP client requires libcurl 8.3.0 or later. Packagist provides the dev-main branch. Install it in the application that calls the exchanger.
Keep the application’s composer.lock so subsequent installs use the same SDK revision. With Composer’s default stability setting, installing without a branch requires a stable release. PHP SDK on Packagist

Send a public ping

Save the example as public-ping.php in your project root. Replace https://your-exchange with your installation’s HTTPS origin, for example by setting EXCHANGER_API_ORIGIN. Use the scheme, host, and optional port. The SDK adds the /api/v3 path.
public-ping.php
Run php public-ping.php. Expect HTTP 200 and an ok status. Public ping

Verify your token and signature with a private ping

Create an API key on a test installation. Load the issued token and secret for the same key from your secret store into the process environment. Pass the token as issued. The SDK constructs the Authorization: Bearer … header. A valid key and signature are sufficient for privatePing(). Save the example as private-ping.php next to the public one and run php private-ping.php.
The SDK generates a fresh nonce and uses the current time for each private call. Keep the application server’s clock synchronized. Private ping · HMAC v2 authentication

Configure timeouts and diagnostics

  • Set the response language with Config(locale: ...) and override it for one call with RequestOptions(locale: ...). Available languages depend on the installation.
  • The built-in Guzzle client uses connectTimeoutSeconds for the connection and timeoutSeconds for the whole request. They default to 5 and 30 seconds. For a test server on loopback, explicitly enable allowInsecureLoopback: true.
  • When using your own PSR-18 transport, configure its timeouts, preserve the signed request bytes, and disable automatic redirects and retries.
  • Use pagination for lists. maxResponseBytes and maxResponseTokens bound the size and complexity of the response. They default to 2 MiB and 50,000 JSON structural tokens.

Handle errors and retries

The exception classes are in the IEXExchanger\Sdk\Api\Exception namespace. The built-in transport leaves retry decisions to your application. For diagnostics, record the HTTP status, requestId, and correlationId from metadata. For 401, check your token, secret, and clock. For 429 or 503, follow the API delay and rate-limit rules. API errors Before creating an order, save the operation key and the exact JSON string from CreateOrderRequest::toJson(). If you lose the response, look up the order first when you already have its ID. If the operation can be retried, pass the same data and key to orders()->create($savedJson, $savedKey). The SDK generates a fresh signature. metadata->idempotencyReplayed reflects the Idempotency-Replayed header. Retention and recovery conditions depend on the operation. Idempotency

More examples