PHPackages                             orkhanahmadov/currencylayer - 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. [HTTP &amp; Networking](/categories/http)
4. /
5. orkhanahmadov/currencylayer

ActiveLibrary[HTTP &amp; Networking](/categories/http)

orkhanahmadov/currencylayer
===========================

PHP client for currencylayer.com

1.1.0(6y ago)041311MITPHPPHP ^7.1CI failing

Since Sep 25Pushed 5y ago1 watchersCompare

[ Source](https://github.com/orkhanahmadov/currencylayer)[ Packagist](https://packagist.org/packages/orkhanahmadov/currencylayer)[ Docs](https://github.com/orkhanahmadov/currencylayer)[ RSS](/packages/orkhanahmadov-currencylayer/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (3)Versions (3)Used By (1)

💱 PHP client for [currencylayer.com](https://currencylayer.com)
===============================================================

[](#currency_exchange-php-client-for-currencylayercom)

[![Latest Stable Version](https://camo.githubusercontent.com/092e39c929f524329b1a80adbfd4682c911460a6fec9eb3888bf4f8373e9a6ac/68747470733a2f2f706f7365722e707567782e6f72672f6f726b68616e61686d61646f762f63757272656e63796c617965722f762f737461626c65)](https://packagist.org/packages/orkhanahmadov/currencylayer)[![Latest Unstable Version](https://camo.githubusercontent.com/ce88d574cabef707c481c82e914bca6a688b66a9e6c6b91b1a53f21130e6b01e/68747470733a2f2f706f7365722e707567782e6f72672f6f726b68616e61686d61646f762f63757272656e63796c617965722f762f756e737461626c65)](https://packagist.org/packages/orkhanahmadov/currencylayer)[![Total Downloads](https://camo.githubusercontent.com/8dcf996efe642e4ac06cff6ad7687c177d8c86810ff13a46afc545c8094ffc2f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6f726b68616e61686d61646f762f63757272656e63796c61796572)](https://packagist.org/packages/orkhanahmadov/currencylayer)[![License](https://camo.githubusercontent.com/9f06e117a8817ee4e0b3c9c2bc5f3040698b0c6d05653108dc7687d9c2426d75/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f6f726b68616e61686d61646f762f63757272656e63796c617965722e737667)](https://github.com/orkhanahmadov/currencylayer/blob/master/LICENSE.md)

[![Build Status](https://camo.githubusercontent.com/6e03c445bd7a7d4ff6741885e162dd25ceb2b6d656f53278314ab6e91997867b/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f6f726b68616e61686d61646f762f63757272656e63796c617965722e737667)](https://travis-ci.org/orkhanahmadov/currencylayer)[![Test Coverage](https://camo.githubusercontent.com/205420245087894e6c6d1010d92ea6577f31d68ae9dd68e557440458d51db202/68747470733a2f2f6170692e636f6465636c696d6174652e636f6d2f76312f6261646765732f61393134653838303439386630626166366237302f746573745f636f766572616765)](https://codeclimate.com/github/orkhanahmadov/currencylayer/test_coverage)[![Maintainability](https://camo.githubusercontent.com/336e48ff23dea296e1832d9064be61b468fbe39802bd40138593a741ad1584f0/68747470733a2f2f6170692e636f6465636c696d6174652e636f6d2f76312f6261646765732f61393134653838303439386630626166366237302f6d61696e7461696e6162696c697479)](https://codeclimate.com/github/orkhanahmadov/currencylayer/maintainability)[![Quality Score](https://camo.githubusercontent.com/15bf9a1f5f1a7eb448903e3adb415aeed55f6c14abbb0d02726c36bf905c9ab8/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f6f726b68616e61686d61646f762f63757272656e63796c617965722e737667)](https://scrutinizer-ci.com/g/orkhanahmadov/currencylayer)[![StyleCI](https://camo.githubusercontent.com/3091d67ed70054e75e6f2d8d0b559fd49ce50725cfbd4b63d0178bf01932cd50/68747470733a2f2f6769746875622e7374796c6563692e696f2f7265706f732f3230393733333032392f736869656c643f6272616e63683d6d6173746572)](https://github.styleci.io/repos/209733029)

Simple PHP client for currencylayer.com currency rates.

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

[](#installation)

You can install the package via composer:

```
composer require orkhanahmadov/currencylayer
```

Usage
-----

[](#usage)

Instantiate `Orkhanahmadov\Currencylayer\CurrencylayerClient` class and pass your "access key"

```
use Orkhanahmadov\Currencylayer\CurrencylayerClient;

$client = new CurrencylayerClient('your-access-key-here');
```

You can find your access key in [Currencylayer Dashboard](https://currencylayer.com/dashboard).

If you are using [paid plan](https://currencylayer.com/product), you can use HTTPS connection to currencylayer.com API. While instantiating pass `true` as second parameter to use HTTPS connection.

```
$client = new CurrencylayerClient('your-access-key-here', true);
```

Available methods
-----------------

[](#available-methods)

### `quotes()`

[](#quotes)

Use this method to fetch live and historical currency rates.

Pass source currency to `source()` method and rate currency `currency()` method. Following example will fetch live rates from USD to EUR.

```
$client->source('USD')->currency('EUR')->quotes();
```

You can also pass multiple rate currencies to `currency()` method:

```
$client->source('USD')->currency('EUR', 'AUD')->quotes();
// you can also pass currencies as an array
$client->source('USD')->currency(['EUR', 'AUD'])->quotes();
```

If you want fetch rates for specific date, you can pass the date to `date()` method. `date()` method accepts dates as string or instance of `DateTimeInterface`.

```
$client->source('USD')->currency('EUR')->date('2019-05-20')->quotes();
```

`quotes()` method returns instance of `Orkhanahmadov\Currencylayer\Data\Quotes`. This class has following methods that you can use:

- `source()` - Returns source currency (for example, `USD`)
- `timestamp()` - Returns timestamp value from currencylayer API (for example, `1432400348`)
- `quotes()` - Returns array of quotes from currencylayer API
- `date()` - Returns `DateTimeInterface` date. If you fetched live rates this method will return `null`

You can also get rates for each fetched currency using currency name as property:

```
$quotes = $client->source('USD')->currency(['EUR', 'AUD'])->date('2019-05-20')->quotes();

$qoutes->EUR; // returns USD to EUR rate for 2019-05-20
$qoutes->AUD; // returns USD to AUD rate for 2019-05-20
```

### `convert()`

[](#convert)

Use this method to convert amount in one currency to another currency.

Pass source currency to `source()` method, rate currency `currency()` method and amount to `convert()` method. Following example will convert 10 USD to GBP using live rates.

```
$client->source('USD')->currency('GBP')->convert(10);
```

If you want conversion based on different date's rates, you can pass the date to `date()` method. `date()` method accepts dates as string or instance of `DateTimeInterface`.

```
$client->source('USD')->currency('GBP')->date('2019-05-20')->convert(10);
```

`convert()` method returns instance of `Orkhanahmadov\Currencylayer\Data\Conversion`. This class has following methods that you can use:

- `fromCurrency()` - Returns source currency (for example, `USD`)
- `toCurrency()` - Returns target currency (for example, `GBP`)
- `timestamp()` - Returns timestamp value from currencylayer API (for example, `1432400348`)
- `amount()` - Returns amount that passed to `convert()` method (for example, `10`)
- `quote()` - Returns quote between source and target currencies (for example, `0.658443`)
- `result()` - Returns conversion result (for example `6.58443`)
- `date()` - Returns `DateTimeInterface` date. If you fetched live rates this method will return `null`

### `timeframe()`

[](#timeframe)

Use this method to show rates between given dates.

Pass source currency to `source()` method, rate currencies to `currency()` method and start date as first argument and end date as second argument to `timeframe()` method. Start and end dates can be string of dates or instances of `DateTimeInterface`.

Following example will return timeframe rates from USD to GBP and EUR between `2010-03-01` and `2010-04-01`.

```
$client->source('USD')->currency('GBP', 'EUR')->timeframe('2010-03-01', '2010-04-01');
```

`timeframe()` method returns instance of `Orkhanahmadov\Currencylayer\Data\Timeframe`. This class has following methods that you can use:

- `source()` - Returns source currency (for example, `USD`)
- `startDate()` - Returns `DateTimeInterface` start date
- `endDate()` - Returns `DateTimeInterface` start date
- `allQuotes()` - Returns array quotes grouped by each day between start and end date
- `quotes()` - Accepts string date or instance of `DateTimeInterface` and returns rates for that day

You can also use currency code as function call and pass date to get rates:

```
$timeframe = $client->source('USD')->currency('GBP', 'EUR')->timeframe('2010-03-01', '2010-04-01');

$timeframe->GBP('2010-03-15'); // returns USD to GBP rate for 2010-03-15
$timeframe->EUR('2010-03-20'); // returns USD to EUR rate for 2010-03-20
```

### `change()`

[](#change)

Use this method to show currency rate change between given dates.

Pass source currency to `source()` method, rate currencies to `currency()` method and start date as first argument and end date as second argument to `change()` method. Start and end dates can be string of dates or instances of `DateTimeInterface`.

Following example will return rate change from USD to GBP and EUR between `2010-03-01` and `2010-04-01`.

```
$client->source('USD')->currency('GBP', 'EUR')->change('2010-03-01', '2010-04-01');
```

`change()` method returns instance of `Orkhanahmadov\Currencylayer\Data\Change`. This class has following methods that you can use:

- `source()` - Returns source currency (for example, `USD`)
- `startDate()` - Returns `DateTimeInterface` start date
- `endDate()` - Returns `DateTimeInterface` start date
- `quotes()` - Returns array of currency change rates between start and end date
- `rate()` - Accepts currency code as an argument and returns currency rate for given start date
- `endRate()` - Accepts currency code as an argument and returns currency rate for given end date
- `amount()` - Accepts currency code as an argument and currency rate's change in amount
- `percentage()` - Accepts currency code as an argument and currency rate's change in percentage

### `list()`

[](#list)

Use this method to get list of all available currencies.

```
$client->list();
```

Method will return array of currencies in `currencyCode => currencyName` structure.

### Testing

[](#testing)

```
composer test
```

### Changelog

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.

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

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

### Security

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

Credits
-------

[](#credits)

- [Orkhan Ahmadov](https://github.com/orkhanahmadov)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity54

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

Total

2

Last Release

2420d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/c82e54991e0224fdc49d34ee60d0cfce5ea0cca1cd59771155e3b372d1fa1d11?d=identicon)[orkhanahmadov](/maintainers/orkhanahmadov)

---

Top Contributors

[![orkhanahmadov](https://avatars.githubusercontent.com/u/7041590?v=4)](https://github.com/orkhanahmadov "orkhanahmadov (55 commits)")

---

Tags

currencycurrencylayerphp-clientcurrencyorkhanahmadovcurrencylayer

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/orkhanahmadov-currencylayer/health.svg)

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

###  Alternatives

[spatie/crawler

Crawl all internal links found on a website

2.8k16.3M52](/packages/spatie-crawler)[akamai-open/edgegrid-client

Implements the Akamai {OPEN} EdgeGrid Authentication specified by https://developer.akamai.com/introduction/Client\_Auth.html

482.5M6](/packages/akamai-open-edgegrid-client)[muhammadhuzaifa/telescope-guzzle-watcher

Telescope Guzzle Watcher provide a custom watcher for intercepting http requests made via guzzlehttp/guzzle php library. The package uses the on\_stats request option for extracting the request/response data. The watcher intercept and log the request into the Laravel Telescope HTTP Client Watcher.

98239.8k1](/packages/muhammadhuzaifa-telescope-guzzle-watcher)[ory/hydra-client-php

Documentation for all of Ory Hydra's APIs.

1710.8k](/packages/ory-hydra-client-php)[meteocontrol/vcom-api-client

HTTP Client for meteocontrol's VCOM API - The VCOM API enables you to directly access your data on the meteocontrol platform.

175.7k1](/packages/meteocontrol-vcom-api-client)

PHPackages © 2026

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