PHPackages                             forexapi/client - 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. forexapi/client

ActiveLibrary[API Development](/categories/api)

forexapi/client
===============

Library for consuming the ForexAPI. Ideal for those in the financial or e-commerce sectors, this client simplifies the process of incorporating real-time forex data into various PHP-based projects.

1.0.1(2y ago)123MITPHPPHP &gt;=7.4

Since Jan 9Pushed 2y ago1 watchersCompare

[ Source](https://github.com/ForexAPI/php-client)[ Packagist](https://packagist.org/packages/forexapi/client)[ Docs](https://forexapi.eu)[ Fund](https://forexapi.eu/pl/pricing)[ RSS](/packages/forexapi-client/feed)WikiDiscussions master Synced 1mo ago

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

[![logo.png](res/banner.png)](https://forexapi.eu)

ForexAPI PHP Client
===================

[](#forexapi-php-client)

[![example workflow](https://github.com/forexapi/php-client/actions/workflows/tests.yaml/badge.svg)](https://github.com/forexapi/php-client/actions/workflows/tests.yaml/badge.svg)[![Latest Stable Version](https://camo.githubusercontent.com/91cfb50821968864a8105585fd975c743eb0d907ae2f021517eb96f857ef4a7c/687474703a2f2f706f7365722e707567782e6f72672f666f7265786170692f636c69656e742f76)](https://packagist.org/packages/forexapi/client)[![Total Downloads](https://camo.githubusercontent.com/6f9070567ec642806d4e24603c277d4af58bd59b8bf7bac57f06a41337793d23/687474703a2f2f706f7365722e707567782e6f72672f666f7265786170692f636c69656e742f646f776e6c6f616473)](https://packagist.org/packages/forexapi/client)[![License](https://camo.githubusercontent.com/c6481ad375fc036713edcf2322a0e3ed070c8a9997b21fbb718609444936e95e/687474703a2f2f706f7365722e707567782e6f72672f666f7265786170692f636c69656e742f6c6963656e7365)](https://packagist.org/packages/forexapi/client)[![PHP Version Require](https://camo.githubusercontent.com/4947923a6d370c0cb66950314180fce91725f9278d472cf949bc2573b7aebeb5/687474703a2f2f706f7365722e707567782e6f72672f666f7265786170692f636c69656e742f726571756972652f706870)](https://packagist.org/packages/forexapi/client)

This is a PHP client for the **ForexAPI**. It provides an easy-to-use interface for interacting with the API's endpoints. The **ForexAPI** offers a free plan and provides foreign exchange rates and currency conversion.
The API documentation can be found at .

[Get a free API key](https://forexapi.eu/)

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

[](#requirements)

- PHP 7.4 or higher
- json extension
- Composer

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

[](#installation)

Use Composer to install the ForexAPI PHP Client:

```
composer require forexapi/client
```

This package does not come with a Http Client. [You can use any PSR-18 compatible client](https://packagist.org/providers/psr/http-client-implementation).
If you have multiple Http Clients installed, [you can specify which one to use](https://github.com/php-http/discovery?tab=readme-ov-file#usage-as-a-library-user).

```
composer require guzzlehttp/guzzle forexapi/client
```

Usage
-----

[](#usage)

Create an instance of the `Client` class directly with your API key:

```
use ForexAPI\Client\Client;

$client = new Client('your-api-key');
```

Create new instance using the `ForexAPI\Client\ForexAPIClientBuilder` class:

```
use \ForexAPI\Client\ForexAPIClientBuilder;

$builder = (new ForexAPIClientBuilder())
    ->withApiKey('your-api-key')
    ->withBaseUri('https://forexapi.eu/api/')
    ->withHttpAdapter($yourCustomHttpAdapter)
    ->build()
;
```

Using your own PSR-18 client and PSR-17 request factory is optional. If you don't provide them, the client will try to discover them automatically.

```
use \ForexAPI\Client\ForexAPIClientBuilder;

$builder = (new ForexAPIClientBuilder())
    ->withApiKey('your-api-key')
    ->withPsr18Client($yourCustomPsr18Client)
    ->withPsr17RequestFactory($yourCustomPsr17RequestFactory)
    ->build()
;
```

### Get Live Quote

[](#get-live-quote)

To get a live quote for a specific currency pair:

```
$quote = $client->getLiveQuote('USD', 'PLN');

echo $quote->getBase(); // USD
echo $quote->getCounter(); // PLN
echo $quote->getBid(); // Bid price
echo $quote->getAsk(); // Ask price
echo $quote->getMid(); // Mid price
echo $quote->getTimestamp(); // Timestamp
```

### Get Exchange Rate

[](#get-exchange-rate)

To get the exchange rate between two currencies:

```
$exchangeRate = $client->getExchangeRate('USD', 'PLN');

echo $exchangeRate->getFrom(); // USD
echo $exchangeRate->getTo(); // PLN
echo $exchangeRate->getRate(); // Exchange rate
echo $exchangeRate->getTimestamp(); // Timestamp
```

If you would like to get multiple exchange rates at once, you can use the `getExchangeRates` method.
It accepts an array of counter currencies as an argument:

```
$exchangeRate = $client->getExchangeRates('USD', ['PLN', 'EUR', 'GBP']);
```

### Convert Currency

[](#convert-currency)

To convert an amount from one currency to another:

```
$conversion = $client->convert('USD', 'PLN', 100.0);

echo $conversion->getFrom(); // USD
echo $conversion->getTo(); // PLN
echo $conversion->getAmount(); // 100.0
echo $conversion->getResult(); // Converted amount in PLN
echo $conversion->getTimestamp(); // Timestamp
```

If you would like to convert to multiple currencies at once, you can use the `convertMany` method:

```
$conversions = $client->convertMany('USD', ['PLN', 'EUR', 'GBP'], 100.0);
```

Testing
-------

[](#testing)

This library includes a suite of unit tests. Run them using PHPUnit:

```
./vendor/bin/phpunit
```

License
-------

[](#license)

This project is licensed under the MIT License. See the LICENSE file for details.

###  Health Score

21

—

LowBetter than 18% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity43

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 ~16 days

Total

2

Last Release

844d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/8d4637fa3a3f4555d58649cee79878d723568a86e7213a4629f8ff4f8a938159?d=identicon)[ForexAPI](/maintainers/ForexAPI)

---

Top Contributors

[![jkobus](https://avatars.githubusercontent.com/u/1527096?v=4)](https://github.com/jkobus "jkobus (10 commits)")

---

Tags

apiapi-clientapi-restcurrencycurrency-convertercurrency-exchange-ratescurrency-ratesexchange-ratesforexapiclientcurrencyconverterexchangeratesfinanceforex

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/forexapi-client/health.svg)

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

###  Alternatives

[openai-php/client

OpenAI PHP is a supercharged PHP API client that allows you to interact with the Open AI API

5.8k22.6M232](/packages/openai-php-client)[getbrevo/brevo-php

Official Brevo provided RESTFul API V3 php library

963.1M35](/packages/getbrevo-brevo-php)[phpro/http-tools

HTTP tools for developing more consistent HTTP implementations.

28137.8k](/packages/phpro-http-tools)[opensearch-project/opensearch-php

PHP Client for OpenSearch

15224.3M65](/packages/opensearch-project-opensearch-php)[mozex/anthropic-php

Anthropic PHP is a supercharged community-maintained PHP API client that allows you to interact with Anthropic API.

46365.1k13](/packages/mozex-anthropic-php)[swisnl/json-api-client

A PHP package for mapping remote JSON:API resources to Eloquent like models and collections.

211473.2k12](/packages/swisnl-json-api-client)

PHPackages © 2026

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