PHPackages                             part-db/swap - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. part-db/swap

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

part-db/swap
============

Fork of florianv/swap modernized for use in Part-DB. Exchange rates library for PHP

v5.0.0(8mo ago)216.6k↑16%11MITPHPPHP ^7.1.3 || ^8.0CI passing

Since Sep 5Pushed 8mo agoCompare

[ Source](https://github.com/Part-DB/swap)[ Packagist](https://packagist.org/packages/part-db/swap)[ RSS](/packages/part-db-swap/feed)WikiDiscussions master Synced 1mo ago

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

[![](https://camo.githubusercontent.com/e9f2edc0c4c1fdecc071323f862b779f03a21b1b4d83746b97fbf4e01f607ac9/68747470733a2f2f73332e616d617a6f6e6177732e636f6d2f737761702e6173736574732f737761705f6c6f676f2e706e67)](https://camo.githubusercontent.com/e9f2edc0c4c1fdecc071323f862b779f03a21b1b4d83746b97fbf4e01f607ac9/68747470733a2f2f73332e616d617a6f6e6177732e636f6d2f737761702e6173736574732f737761705f6c6f676f2e706e67) Swap
==============================================================================================================================================================================================================================================================================================================================================================================================================================

[](#-swap)

**This is a fork of [florianv/swap](https://github.com/florianv/swap) for the use in Part-DB.**

Swap allows you to retrieve currency exchange rates from various services such as **[Fixer](https://fixer.io/)**, **[Currency Data](https://currencylayer.com)** or **[Exchange Rates Data](https://exchangeratesapi.io/)** and optionally cache the results. It is integrated to other libraries like [moneyphp/money](https://github.com/moneyphp/money) and provides a [Symfony Bundle](https://github.com/florianv/FlorianvSwapBundle) and a [Laravel Package](https://github.com/florianv/laravel-swap).

Sponsors
--------

[](#sponsors)

  [![](https://camo.githubusercontent.com/0d10ffe181170f80111526baf4835225593324a3e10e8c3cf0f396549a9b6d9c/68747470733a2f2f6173736574732e6170696c617965722e636f6d2f617069732f66697865722e706e67)](https://camo.githubusercontent.com/0d10ffe181170f80111526baf4835225593324a3e10e8c3cf0f396549a9b6d9c/68747470733a2f2f6173736574732e6170696c617965722e636f6d2f617069732f66697865722e706e67) [Fixer](https://fixer.io/) is a simple and lightweight API for foreign exchange rates that supports up to 170 world currencies.   [![](https://camo.githubusercontent.com/7fcddd392c51aee3d78852b41590841f7186fab34870b5dc50f90989fd1a56b7/68747470733a2f2f6173736574732e6170696c617965722e636f6d2f617069732f63757272656e63795f646174612e706e67)](https://camo.githubusercontent.com/7fcddd392c51aee3d78852b41590841f7186fab34870b5dc50f90989fd1a56b7/68747470733a2f2f6173736574732e6170696c617965722e636f6d2f617069732f63757272656e63795f646174612e706e67) [currencylayer](https://currencylayer.com) provides reliable exchange rates and currency conversions for your business up to 168 world currencies.   [![](https://camo.githubusercontent.com/a1f40efebb340530a15ac4fb946a8657b802aece08961e29c8e3ca9cac2dba36/68747470733a2f2f6173736574732e6170696c617965722e636f6d2f617069732f65786368616e676572617465735f646174612e706e67)](https://camo.githubusercontent.com/a1f40efebb340530a15ac4fb946a8657b802aece08961e29c8e3ca9cac2dba36/68747470733a2f2f6173736574732e6170696c617965722e636f6d2f617069732f65786368616e676572617465735f646174612e706e67) [exchangerates](https://exchangeratesapi.io/) provides reliable exchange rates and currency conversions for your business with over 15 data sources. QuickStart
----------

[](#quickstart)

```
$ composer require php-http/curl-client nyholm/psr7 php-http/message part-db/swap
```

```
use Swap\Builder;

// Build Swap
$swap = (new Builder())

    // Use the Fixer service as first level provider
    ->add('apilayer_fixer', ['api_key' => 'Get your key here: https://fixer.io/'])

    // Use the currencylayer service as first fallback
    ->add('apilayer_currency_data', ['api_key' => 'Get your key here: https://currencylayer.com'])

    // Use the exchangerates service as second fallback
    ->add('apilayer_exchange_rates_data', ['api_key' => 'Get your key here: https://exchangeratesapi.io/'])
->build();

// Get the latest EUR/USD rate
$rate = $swap->latest('EUR/USD');

// 1.129
$rate->getValue();

// 2016-08-26
$rate->getDate()->format('Y-m-d');

// Get the EUR/USD rate 15 days ago
$rate = $swap->historical('EUR/USD', (new \DateTime())->modify('-15 days'));
```

> We recommend to use the [services that support our project](#sponsors), providing a free plan up to 100 requests per month.

Documentation
-------------

[](#documentation)

The documentation for the current branch can be found [here](https://github.com/florianv/swap/blob/master/doc/readme.md).

Services
--------

[](#services)

Here is the list of the currently implemented services:

ServiceBase CurrencyQuote CurrencyHistorical[Fixer](https://fixer.io/)EUR (free, no SSL), \* (paid)\*Yes[Currency Data](https://currencylayer.com)USD (free), \* (paid)\*Yes[Exchange Rates Data](https://exchangeratesapi.io/)USD (free), \* (paid)\*Yes[Abstract](https://www.abstractapi.com)\*\*Yes[coinlayer](https://coinlayer.com)\* Crypto (Limited standard currencies)\* Crypto (Limited standard currencies)Yes[Fixer](https://fixer.io)EUR (free, no SSL), \* (paid)\*Yes[Currency Data](https://currencylayer.com)USD (free), \* (paid)\*Yes[exchangeratesapi](https://exchangeratesapi.io)USD (free), \* (paid)\*Yes[European Central Bank](https://www.ecb.europa.eu/home/html/index.en.html)EUR\*Yes[National Bank of Georgia](https://nbg.gov.ge)\*GELYes[National Bank of the Republic of Belarus](https://www.nbrb.by)\*BYN (from 01-07-2016),
BYR (01-01-2000 - 30-06-2016),
BYB (25-05-1992 - 31-12-1999)Yes[National Bank of Romania](http://www.bnr.ro)RON, AED, AUD, BGN, BRL, CAD, CHF, CNY, CZK, DKK, EGP, EUR, GBP, HRK, HUF, INR, JPY, KRW, MDL, MXN, NOK, NZD, PLN, RSD, RUB, SEK, TRY, UAH, USD, XAU, XDR, ZARRON, AED, AUD, BGN, BRL, CAD, CHF, CNY, CZK, DKK, EGP, EUR, GBP, HRK, HUF, INR, JPY, KRW, MDL, MXN, NOK, NZD, PLN, RSD, RUB, SEK, TRY, UAH, USD, XAU, XDR, ZARYes[National Bank of Ukranie](https://bank.gov.ua)\*UAHYes[Central Bank of the Republic of Turkey](http://www.tcmb.gov.tr)\*TRYYes[Central Bank of the Republic of Uzbekistan](https://cbu.uz)\*UZSYes[Central Bank of the Czech Republic](https://www.cnb.cz)\*CZKYes[Central Bank of Russia](https://cbr.ru)\*RUBYes[Bulgarian National Bank](http://bnb.bg)\*BGNYes[WebserviceX](http://www.webservicex.net)\*\*No[1Forge](https://1forge.com)\* (free but limited or paid)\* (free but limited or paid)No[Cryptonator](https://www.cryptonator.com)\* Crypto (Limited standard currencies)\* Crypto (Limited standard currencies)No[CurrencyDataFeed](https://currencydatafeed.com)\* (free but limited or paid)\* (free but limited or paid)No[Open Exchange Rates](https://openexchangerates.org)USD (free), \* (paid)\*Yes[Xignite](https://www.xignite.com)\*\*Yes[Currency Converter API](https://www.currencyconverterapi.com)\*\*Yes (free but limited or paid)[xChangeApi.com](https://xchangeapi.com)\*\*Yes[fastFOREX.io](https://www.fastforex.io)USD (free), \* (paid)\*No[exchangerate.host](https://www.exchangerate.host)\*\*YesArray\*\*YesAdditionally, you can add your own services as long as they implement the `ExchangeRateService` interface.

Integrations
------------

[](#integrations)

- A Symfony Bundle [FlorianvSwapBundle](https://github.com/florianv/FlorianvSwapBundle)
- A Laravel Package [florianv/laravel-swap](https://github.com/florianv/laravel-swap)

Credits
-------

[](#credits)

- [Florian Voutzinos](https://github.com/florianv)
- [All Contributors](https://github.com/florianv/swap/contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [LICENSE](https://github.com/florianv/swap/blob/master/LICENSE) for more information.

###  Health Score

40

—

FairBetter than 88% of packages

Maintenance60

Regular maintenance activity

Popularity32

Limited adoption so far

Community20

Small or concentrated contributor base

Maturity40

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 81.9% 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

255d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/966f0c4a6fd593c7a9e3e0c950f4e44dfa6caaf09609500cdce765b1eba7a855?d=identicon)[jbtronics](/maintainers/jbtronics)

---

Top Contributors

[![florianv](https://avatars.githubusercontent.com/u/1586668?v=4)](https://github.com/florianv "florianv (226 commits)")[![Nyholm](https://avatars.githubusercontent.com/u/1275206?v=4)](https://github.com/Nyholm "Nyholm (20 commits)")[![ddinchev](https://avatars.githubusercontent.com/u/1397692?v=4)](https://github.com/ddinchev "ddinchev (4 commits)")[![ahubers](https://avatars.githubusercontent.com/u/7432558?v=4)](https://github.com/ahubers "ahubers (4 commits)")[![jbtronics](https://avatars.githubusercontent.com/u/5410681?v=4)](https://github.com/jbtronics "jbtronics (4 commits)")[![vinkla](https://avatars.githubusercontent.com/u/499192?v=4)](https://github.com/vinkla "vinkla (2 commits)")[![albertodiaz](https://avatars.githubusercontent.com/u/1932161?v=4)](https://github.com/albertodiaz "albertodiaz (2 commits)")[![tyx](https://avatars.githubusercontent.com/u/245494?v=4)](https://github.com/tyx "tyx (2 commits)")[![ugurerkan](https://avatars.githubusercontent.com/u/473959?v=4)](https://github.com/ugurerkan "ugurerkan (2 commits)")[![avataru](https://avatars.githubusercontent.com/u/209354?v=4)](https://github.com/avataru "avataru (1 commits)")[![arjanwestdorp](https://avatars.githubusercontent.com/u/7716654?v=4)](https://github.com/arjanwestdorp "arjanwestdorp (1 commits)")[![necenzurat](https://avatars.githubusercontent.com/u/145449?v=4)](https://github.com/necenzurat "necenzurat (1 commits)")[![andreicio](https://avatars.githubusercontent.com/u/20474012?v=4)](https://github.com/andreicio "andreicio (1 commits)")[![pascalheidmann](https://avatars.githubusercontent.com/u/19560252?v=4)](https://github.com/pascalheidmann "pascalheidmann (1 commits)")[![pborreli](https://avatars.githubusercontent.com/u/77759?v=4)](https://github.com/pborreli "pborreli (1 commits)")[![rickogden](https://avatars.githubusercontent.com/u/135672?v=4)](https://github.com/rickogden "rickogden (1 commits)")[![0xflotus](https://avatars.githubusercontent.com/u/26602940?v=4)](https://github.com/0xflotus "0xflotus (1 commits)")[![dannyweeks](https://avatars.githubusercontent.com/u/4365775?v=4)](https://github.com/dannyweeks "dannyweeks (1 commits)")[![Chris8934](https://avatars.githubusercontent.com/u/44963939?v=4)](https://github.com/Chris8934 "Chris8934 (1 commits)")

---

Tags

moneycurrencyconversionRateexchange rates

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/part-db-swap/health.svg)

```
[![Health](https://phpackages.com/badges/part-db-swap/health.svg)](https://phpackages.com/packages/part-db-swap)
```

###  Alternatives

[florianv/swap

Exchange rates library for PHP

1.3k6.4M16](/packages/florianv-swap)[florianv/laravel-swap

Currency exchange rates library for Laravel and Lumen

3342.0M2](/packages/florianv-laravel-swap)[florianv/exchanger

Currency exchange rates framework for PHP

1874.7M15](/packages/florianv-exchanger)[brick/money

Money and currency library

1.9k37.9M102](/packages/brick-money)[ujjwal/currency-converter

Currency Converter Class with features of caching and identifying currency from country Code

49225.4k](/packages/ujjwal-currency-converter)[florianv/swap-bundle

Integrates the Swap library with Symfony

62416.1k1](/packages/florianv-swap-bundle)

PHPackages © 2026

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