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

ActiveLibrary[API Development](/categories/api)

xratesapi/php-sdk
=================

Official PHP SDK for the XRates exchange rate API — multi-source FX rates with a single REST endpoint.

v0.1.0(2mo ago)00MITPHPPHP ^8.1

Since May 9Pushed 2mo agoCompare

[ Source](https://github.com/xratesapi/php-sdk)[ Packagist](https://packagist.org/packages/xratesapi/php-sdk)[ Docs](https://xratesapi.com)[ RSS](/packages/xratesapi-php-sdk/feed)WikiDiscussions main Synced 3w ago

READMEChangelogDependencies (2)Versions (2)Used By (0)

XRates PHP SDK
==============

[](#xrates-php-sdk)

Official PHP client for the [XRates](https://xratesapi.com) exchange rate API. Multi-source FX rates aggregated from ECB, CBR, FloatRates, fawazahmed0 and IMF, served via a single REST endpoint.

[![Latest Stable Version](https://camo.githubusercontent.com/1028e24db90e164bde5f409dbead66d0c3c334167ea2d1da33c250ea9c7c22ab/68747470733a2f2f706f7365722e707567782e6f72672f7872617465736170692f7068702d73646b2f76)](https://packagist.org/packages/xratesapi/php-sdk)[![Total Downloads](https://camo.githubusercontent.com/17e8a7555d3f96803b0241970236a1359cd32d1eb23a5ddb45a1624f2a975053/68747470733a2f2f706f7365722e707567782e6f72672f7872617465736170692f7068702d73646b2f646f776e6c6f616473)](https://packagist.org/packages/xratesapi/php-sdk)[![PHP Version Require](https://camo.githubusercontent.com/f4fea66ff3d9aa63749b182f6d4a307f1ed6af32c12079f10de1294d5e7d6e1f/68747470733a2f2f706f7365722e707567782e6f72672f7872617465736170692f7068702d73646b2f726571756972652f706870)](https://packagist.org/packages/xratesapi/php-sdk)[![License](https://camo.githubusercontent.com/ba91b09a90e39919106e72b63af2a339aa6be26c68a6da9241deb3a61f294d70/68747470733a2f2f706f7365722e707567782e6f72672f7872617465736170692f7068702d73646b2f6c6963656e7365)](https://packagist.org/packages/xratesapi/php-sdk)

- **Documentation:**
- **Free tier:** 100 requests/month, no credit card — [sign up](https://xratesapi.com/register)
- **Status:**

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

[](#requirements)

- PHP 8.1+
- Guzzle 7.5+ (or any PSR-compatible HTTP client)

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

[](#installation)

```
composer require xratesapi/php-sdk
```

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

[](#quick-start)

```
use XRatesApi\Client;

$client = new Client('YOUR_API_KEY');

// Latest rates: rates[T] = "X T per 1 base"
$response = $client->latest('USD', ['EUR', 'GBP']);
// ['base' => 'USD', 'rates' => ['EUR' => 0.864, 'GBP' => 0.79], ...]

// Historical
$response = $client->historical('2026-05-01', 'USD', ['EUR']);

// Convert an amount
$response = $client->convert('USD', 'EUR', 100.0);
// ['from' => 'USD', 'to' => 'EUR', 'amount' => 100, 'result' => 86.4]

// Time-series
$response = $client->timeseries('2026-01-01', '2026-01-31', 'USD', ['EUR']);

// Rate fluctuation
$response = $client->fluctuation('2026-01-01', '2026-01-31', 'USD', ['EUR']);

// Currencies
$response = $client->currencies();

// Public status (no API key required, but the client sends one anyway)
$response = $client->status();
```

Error handling
--------------

[](#error-handling)

Every HTTP error maps to one of four exception types, all extending `XRatesApi\Exceptions\ApiException`:

HTTPExceptionWhen401 / 403`AuthenticationException`Missing or invalid API key422`ValidationException`Bad request parameters; `->payload()` has the full error array429`RateLimitException`Hit the per-plan rate limitother`ApiException`Network errors, 5xx, unexpected responses```
use XRatesApi\Exceptions\RateLimitException;
use XRatesApi\Exceptions\ApiException;

try {
    $rates = $client->latest('USD', ['EUR']);
} catch (RateLimitException $e) {
    // back off and retry
} catch (ApiException $e) {
    // log and surface to caller
    error_log("XRates: " . $e->getMessage());
}
```

Custom HTTP client
------------------

[](#custom-http-client)

The constructor accepts any `\GuzzleHttp\ClientInterface`, so you can plug in your own configured client (timeouts, retry middleware, proxy, etc.):

```
$guzzle = new \GuzzleHttp\Client([
    'timeout' => 5,
    'connect_timeout' => 2,
]);

$client = new Client('YOUR_API_KEY', $guzzle);
```

Custom base URL
---------------

[](#custom-base-url)

Useful for tests or self-hosted deployments:

```
$client = new Client('YOUR_API_KEY', null, 'https://staging.xratesapi.com');
```

Versioning
----------

[](#versioning)

This SDK follows semver. The `Client::VERSION` constant is sent in the `User-Agent` header on every request, which helps us debug integration issues if you contact support.

Contributing
------------

[](#contributing)

PRs welcome. Run the tests:

```
composer install
composer test
```

License
-------

[](#license)

MIT — see `LICENSE` file.

###  Health Score

32

—

LowBetter than 69% of packages

Maintenance85

Actively maintained with recent releases

Popularity0

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity32

Early-stage or recently created project

 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

76d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/1b4331d4fdbefb2ec8a67cb6b2561d03c914f052df3da14da3206a1304218db8?d=identicon)[xratesapi](/maintainers/xratesapi)

---

Top Contributors

[![alexeimolin](https://avatars.githubusercontent.com/u/3444666?v=4)](https://github.com/alexeimolin "alexeimolin (2 commits)")

---

Tags

currencycurrency-apiexchange-rateexchange-rate-apiforexfx-rateslaravelphpphp-sdkcurrencycurrency conversionexchange ratefxfx\_ratescurrency-apiexchange-rate-apixrates

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[tencentcloud/tencentcloud-sdk-php

TencentCloudApi php sdk

3661.3M47](/packages/tencentcloud-tencentcloud-sdk-php)[eslazarev/wildberries-sdk

Wildberries OpenAPI clients (generated).

293.1k](/packages/eslazarev-wildberries-sdk)[files.com/files-php-sdk

Files.com PHP SDK

2481.1k](/packages/filescom-files-php-sdk)[aimeos/prisma

A powerful PHP package for integrating media related Large Language Models (LLMs) into your applications

1943.1k5](/packages/aimeos-prisma)[otherguy/php-currency-api

A PHP API Wrapper to offer a unified programming interface for popular Currency Rate APIs.

2526.8k](/packages/otherguy-php-currency-api)[volcengine/volcengine-php-sdk

118.7k](/packages/volcengine-volcengine-php-sdk)

PHPackages © 2026

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