PHPackages                             mrzard/open-exchange-rates-service - 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. mrzard/open-exchange-rates-service

ActiveLibrary[API Development](/categories/api)

mrzard/open-exchange-rates-service
==================================

OpenExchangeRates API exposure

v1.1.2(8y ago)169.2k—9%21MITPHPPHP &gt;=5.6.0

Since Aug 4Pushed 8y ago1 watchersCompare

[ Source](https://github.com/mrzard/OpenExchangeRates)[ Packagist](https://packagist.org/packages/mrzard/open-exchange-rates-service)[ RSS](/packages/mrzard-open-exchange-rates-service/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (5)Dependencies (2)Versions (10)Used By (1)

OpenExchangeRates Service
=========================

[](#openexchangerates-service)

[![SensioLabsInsight](https://camo.githubusercontent.com/25bc2b40195181e573fe82c1c13dee757a81ab9efc0f5d54690820e5541bd982/68747470733a2f2f696e73696768742e73656e73696f6c6162732e636f6d2f70726f6a656374732f65616333373038622d343136632d346663362d396335302d3435336435346666386639312f6d696e692e706e67)](https://insight.sensiolabs.com/projects/eac3708b-416c-4fc6-9c50-453d54ff8f91)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/4eb02bb4dd89cb6914b124947156cdd75825c493b5fa47525d29b560badee2f4/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6d727a6172642f4f70656e45786368616e676552617465732f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/mrzard/OpenExchangeRates/?branch=master)[![Build Status](https://camo.githubusercontent.com/84ecdd0fdcad8e13cbb749d30b4ca98032f0ac592d49754366d7f188991fbd3b/68747470733a2f2f7472617669732d63692e6f72672f6d727a6172642f4f70656e45786368616e676552617465732e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/mrzard/OpenExchangeRates)

This service will help you use OpenExchangeRates in your project

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

[](#installation)

Use composer to require and install the service

```
$ php composer.phar require mrzard/open-exchange-rates-service ~1.0.0
```

Configuration
-------------

[](#configuration)

When creating an instance of the service, you will have to provide the basic data needed for accessing the OpenExchangeRates API and a HTTP client **compatible** with `HttpClientInterface` like `GuzzleHttp\Client`

```
    use Mrzard\OpenExchangeRates\Service\OpenExchangeRatesService;
    use GuzzleHttp\Client;
    ...

    $apiOptions = array(
        'https' => false,
        'base_currency' => 'USD'
    );

    new OpenExchangeRatesService(
        $openExchangeRatesApiId, // your id from openExchangeRatesApi
        $apiOptions,
        new Client()
    );
    ...
```

If you're using a free version, you won't need to change the `https` or `base_currency` as they only work for Enterprise/Unlimited accounts

Note on HTTP client
-------------------

[](#note-on-http-client)

**compatible** in current context means that the client MUST have methods with next signatures:

```
public HttpRequestInterface request(string method, string url = null, array $options = []);

public HttpResponseInterface send(HttpRequestInterface request);

```

Also wrapper doesn't require returned values to implement that interface, but MUST be also compatible

Usage
-----

[](#usage)

Free features
-------------

[](#free-features)

### Get latest exchange rates

[](#get-latest-exchange-rates)

```
    /**
     * Get the latest exchange rates
     *
     * @param array  $symbols Currency codes to get the rates for. Default all
     * @param string $base    Base currency, default NULL (gets it from config)
     *
     * @return array
     */
    public function getLatest($symbols = array, $base = null)
    {
    }
```

Only use the `$symbols` and `$base` parameters if you have an Enterprise or Unlimited plan.

Output:

```
    array (size=5)

          'disclaimer' => string 'Exchange rates...'

          'license' => string 'Data sourced from...'

          'timestamp' => int 1395396061

          'base' => string 'USD' (length=3)

          'rates' =>

                array (size=166)

                  'AED' => float 3.672721

                  'AFN' => float 56.747225

                  'ALL' => float 101.7573

                  'AMD' => float 417.366998

                  ...
            )
    )
```

### Get available currencies

[](#get-available-currencies)

```
    /**
     * Gets a list of all available currencies
     *
     * @return array with keys = ISO codes, content = Currency Name
     */
    public function getCurrencies()
    {
    }
```

Output:

```
    array (size=5)

          'AED' => 'United Arab Emirates Dirham'

          'AFN' => 'Afghan Afghani'

          'ALL' => 'Albanian Lek'

          'AMD' => 'Armenian Dram'

          'ANG' => 'Netherlands Antillean Guilder'

          ...

    )
```

### Get historical data for a date

[](#get-historical-data-for-a-date)

```
    /**
     * Get historical data
     *
     * @param \DateTime $date
     * @param array  $symbols array of currency codes to get the rates for.
     *                        Default empty (all currencies)
     * @param string $base    Base currency, default NULL (gets it from config)
     *
     */
    public function getHistorical(\DateTime $date)
    {
    }
```

Only use the `$symbols` and `$base` parameters if you have a Developer, Enterprise or Unlimited plan.

Output:

```
    array (size=5)

        'disclaimer' => string 'Exchange rates...'

        'license' => string 'Data sourced from...'

        'timestamp' => int 1388617200

        'base' => string 'USD' (length=3)

        'rates' =>

            array (size=166)

                'AED' => float 3.672524

                'AFN' => float 56.0846

                'ALL' => float 102.06575

                'AMD' => float 408.448002

                'ANG' => float 1.78902

                'AOA' => float 97.598401

                'ARS' => float 6.51658

                'AUD' => float 1.124795

                'AWG' => float 1.789775

                'AZN' => float 0.7841

                'BAM' => float 1.421715

                'BBD' => int 2
          ...
        )
    )
```

Developer / Unlimited features
------------------------------

[](#developer--unlimited-features)

### Get the latest exchange rates, limiting the return array

[](#get-the-latest-exchange-rates-limiting-the-return-array)

```
    $openExchangeRatesService->getLatest(array('EUR', 'USD', 'COP'));
```

Output:

```
    array (size=5)

          'disclaimer' => string 'Exchange rates ...'

          'license' => string 'Data sourced...'

          'timestamp' => int 1395396061

          'base' => string 'USD' (length=3)

          'rates' =>

                array (size=3)

                  'EUR' => ...,

                  'USD' => ...,

                  'COP' => ...

                )

    )
```

You can also change the base currency used to get the latest exchange rates with the second parameter

### Directly convert a quantity between currencies

[](#directly-convert-a-quantity-between-currencies)

```
    $openExchangeRatesService->convert(10, 'USD', 'EUR');
```

###  Health Score

37

—

LowBetter than 83% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity33

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity64

Established project with proven stability

 Bus Factor1

Top contributor holds 64.3% 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 ~152 days

Recently: every ~220 days

Total

9

Last Release

3090d ago

Major Versions

v0.2.0 → v1.0.02016-07-06

PHP version history (4 changes)v0.0.1PHP &gt;=5.3.0

v0.1.0PHP &gt;=5.4.0

v1.0.0PHP &gt;=5.5.0

v1.1.0PHP &gt;=5.6.0

### Community

Maintainers

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

---

Top Contributors

[![mrzard](https://avatars.githubusercontent.com/u/1557869?v=4)](https://github.com/mrzard "mrzard (9 commits)")[![sovaalexandr](https://avatars.githubusercontent.com/u/3388993?v=4)](https://github.com/sovaalexandr "sovaalexandr (2 commits)")[![xaviervreasy](https://avatars.githubusercontent.com/u/31613882?v=4)](https://github.com/xaviervreasy "xaviervreasy (2 commits)")[![jfortunato](https://avatars.githubusercontent.com/u/1606681?v=4)](https://github.com/jfortunato "jfortunato (1 commits)")

---

Tags

currencyexchangeopenexchangerates

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/mrzard-open-exchange-rates-service/health.svg)

```
[![Health](https://phpackages.com/badges/mrzard-open-exchange-rates-service/health.svg)](https://phpackages.com/packages/mrzard-open-exchange-rates-service)
```

###  Alternatives

[maciej-sz/nbp-php

API for accessing Polish National Bank (NBP - Narodowy Bank Polski) currency and commodities exchange rates

1343.3k1](/packages/maciej-sz-nbp-php)[coinpaymentsnet/coinpayments-php

A PHP wrapper for the CoinPayments.net v1 API.

55126.2k](/packages/coinpaymentsnet-coinpayments-php)[currency-cloud/client

A PHP library which implements the complete functionality of v2 of the The Currency Cloud API.

17327.2k](/packages/currency-cloud-client)[aveiv/open-exchange-rates-api

PHP wrapper for Open Exchange Rates API

10292.3k](/packages/aveiv-open-exchange-rates-api)[stichoza/nbg-currency

National Bank of Georgia (NBG) currency service API wrapper

2925.2k1](/packages/stichoza-nbg-currency)[otherguy/php-currency-api

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

2526.2k](/packages/otherguy-php-currency-api)

PHPackages © 2026

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