PHPackages                             openwse/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. openwse/swap

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

openwse/swap
============

Exchange rates library for PHP

4.3.1(4y ago)091MITPHPPHP ^7.1.3 || ^8.0

Since May 12Pushed 4y agoCompare

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

READMEChangelog (1)Dependencies (5)Versions (34)Used By (1)

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

[](#-swap)

[![Build status](https://camo.githubusercontent.com/a67b13d612939b229c57bcf71178a543c473517408afc4c7b58ca28e9c3a82d4/687474703a2f2f696d672e736869656c64732e696f2f7472617669732f666c6f7269616e762f737761702e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/florianv/swap)[![Total Downloads](https://camo.githubusercontent.com/2cb2c020e35039d0a628d7fda792e56dae45c5e762d01ebcd3ce4412706e0641/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f666c6f7269616e762f737761702e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/florianv/swap)[![Scrutinizer](https://camo.githubusercontent.com/b208ad777b89e4408ba323148074aab2a418a5e586c515f066a1f500f328a1e8/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f666c6f7269616e762f737761702e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/florianv/swap)[![Version](https://camo.githubusercontent.com/cba7b599a887890e9306165e8924f64a54722670d7d6c13daf63bda96279d615/687474703a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f666c6f7269616e762f737761702e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/florianv/swap)

Swap allows you to retrieve currency exchange rates from various services such as **[Fixer](https://fixer.io)**, **[currencylayer](https://currencylayer.com)**, **[exchangeratesapi](https://exchangeratesapi.io)** or **[Abstract](https://www.abstractapi.com)** 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/8ca444a24633a18b613b34304afdb3c6eb567477ab47fa409b2256b8b2b9db92/68747470733a2f2f73332e616d617a6f6e6177732e636f6d2f737761702e6173736574732f66697865725f69636f6e2e706e673f763d32)](https://camo.githubusercontent.com/8ca444a24633a18b613b34304afdb3c6eb567477ab47fa409b2256b8b2b9db92/68747470733a2f2f73332e616d617a6f6e6177732e636f6d2f737761702e6173736574732f66697865725f69636f6e2e706e673f763d32) [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/077e83e24e837da81df47eb21cd4d2bfbc61879211243dc666314fc22108f918/68747470733a2f2f73332e616d617a6f6e6177732e636f6d2f737761702e6173736574732f63757272656e63796c617965725f69636f6e2e706e67)](https://camo.githubusercontent.com/077e83e24e837da81df47eb21cd4d2bfbc61879211243dc666314fc22108f918/68747470733a2f2f73332e616d617a6f6e6177732e636f6d2f737761702e6173736574732f63757272656e63796c617965725f69636f6e2e706e67) [currencylayer](https://currencylayer.com) provides reliable exchange rates and currency conversions for your business up to 168 world currencies.   [![](https://camo.githubusercontent.com/ed7ef6d123343df057690fe1abda6b27f2a12c160569772bee98e09bbd17c3f1/68747470733a2f2f65786368616e676572617465736170692e696f2f6173736574732f696d616765732f6170692d6c6f676f2e737667)](https://camo.githubusercontent.com/ed7ef6d123343df057690fe1abda6b27f2a12c160569772bee98e09bbd17c3f1/68747470733a2f2f65786368616e676572617465736170692e696f2f6173736574732f696d616765732f6170692d6c6f676f2e737667) [exchangeratesapi](https://exchangeratesapi.io) provides reliable exchange rates and currency conversions for your business with over 15 data sources.   [![](https://camo.githubusercontent.com/2368b322f25b7b03e11bc7f59f0256397a2cbcbd14fc0f923d91d14dfa24f902/68747470733a2f2f676c6f62616c2d75706c6f6164732e776562666c6f772e636f6d2f3565626264306135363661333939363633366535353935392f3565633262613237656465393833393137646266663232665f66617669636f6e2e706e67)](https://camo.githubusercontent.com/2368b322f25b7b03e11bc7f59f0256397a2cbcbd14fc0f923d91d14dfa24f902/68747470733a2f2f676c6f62616c2d75706c6f6164732e776562666c6f772e636f6d2f3565626264306135363661333939363633366535353935392f3565633262613237656465393833393137646266663232665f66617669636f6e2e706e67) [Abstract](https://www.abstractapi.com/) provides simple exchange rates for developers and a dozen of APIs covering thousands of use cases.  QuickStart
----------

[](#quickstart)

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

```
use Swap\Builder;

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

    // Use the Fixer.io service as first level provider
    ->add('fixer', ['access_key' => 'your-access-key'])

    // Use the currencylayer.com service as first fallback
    ->add('currency_layer', ['access_key' => 'secret', 'enterprise' => false])

    // Use the exchangeratesapi.io service as second fallback
    ->add('exchange_rates_api', ['access_key' => 'secret'])

    // Use the abstractapi.com service as third fallback
    ->add('abstract_api', ['api_key' => 'secret'])
->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 1,000 requests per day.

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[currencylayer](https://currencylayer.com)USD (free), \* (paid)\*Yes[exchangeratesapi](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[European Central Bank](https://www.ecb.europa.eu/home/html/index.en.html)EUR\*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[Central Bank of the Republic of Turkey](http://www.tcmb.gov.tr)\*TRYYes[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)\*NoArray\*\*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

33

—

LowBetter than 72% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community19

Small or concentrated contributor base

Maturity79

Established project with proven stability

 Bus Factor1

Top contributor holds 83.1% 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 ~89 days

Recently: every ~252 days

Total

33

Last Release

1583d ago

Major Versions

1.x-dev → v2.0.02015-01-15

v2.6.0 → v3.0.02016-09-18

v2.6.1 → 3.3.02018-02-19

3.5.0 → 4.0.02019-02-12

PHP version history (6 changes)v1.0.0PHP &gt;=5.3.3

v2.0.0PHP &gt;=5.4.0

v3.0.0PHP ^5.5|^7.0

3.0.2PHP ^5.5 || ^7.0

4.0.0PHP ^7.1.3

4.3.0PHP ^7.1.3 || ^8.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/74194234?v=4)[openwse](/maintainers/openwse)[@openwse](https://github.com/openwse)

---

Top Contributors

[![florianv](https://avatars.githubusercontent.com/u/1586668?v=4)](https://github.com/florianv "florianv (216 commits)")[![Nyholm](https://avatars.githubusercontent.com/u/1275206?v=4)](https://github.com/Nyholm "Nyholm (20 commits)")[![ahubers](https://avatars.githubusercontent.com/u/7432558?v=4)](https://github.com/ahubers "ahubers (4 commits)")[![ddinchev](https://avatars.githubusercontent.com/u/1397692?v=4)](https://github.com/ddinchev "ddinchev (4 commits)")[![vinkla](https://avatars.githubusercontent.com/u/499192?v=4)](https://github.com/vinkla "vinkla (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)")[![albertodiaz](https://avatars.githubusercontent.com/u/1932161?v=4)](https://github.com/albertodiaz "albertodiaz (2 commits)")[![necenzurat](https://avatars.githubusercontent.com/u/145449?v=4)](https://github.com/necenzurat "necenzurat (1 commits)")[![arjanwestdorp](https://avatars.githubusercontent.com/u/7716654?v=4)](https://github.com/arjanwestdorp "arjanwestdorp (1 commits)")[![avataru](https://avatars.githubusercontent.com/u/209354?v=4)](https://github.com/avataru "avataru (1 commits)")[![dannyweeks](https://avatars.githubusercontent.com/u/4365775?v=4)](https://github.com/dannyweeks "dannyweeks (1 commits)")[![0xflotus](https://avatars.githubusercontent.com/u/26602940?v=4)](https://github.com/0xflotus "0xflotus (1 commits)")[![openwse](https://avatars.githubusercontent.com/u/74194234?v=4)](https://github.com/openwse "openwse (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)")

---

Tags

moneycurrencyconversionRateexchange rates

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[florianv/swap

PHP currency conversion library for retrieving exchange rates from 30+ providers, with caching and fallback.

1.3k6.8M23](/packages/florianv-swap)[brick/money

Money and currency library

1.9k41.8M153](/packages/brick-money)[ujjwal/currency-converter

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

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

Drop-in Symfony bundle for currency conversion: configurable services, multi-provider exchange rates with fallback and caching.

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

PHPackages © 2026

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