PHPackages                             forexrateapi/forexrateapi-php - 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. forexrateapi/forexrateapi-php

ActiveLibrary[API Development](/categories/api)

forexrateapi/forexrateapi-php
=============================

Official PHP wrapper for ForexRateAPI.com - Foreign exchange rate API and currency conversion API

1.3.0(2mo ago)01MITPHPPHP &gt;=7.4

Since Feb 25Pushed 2mo agoCompare

[ Source](https://github.com/forexrateapi/forexrateapi-php)[ Packagist](https://packagist.org/packages/forexrateapi/forexrateapi-php)[ Docs](https://forexrateapi.com)[ RSS](/packages/forexrateapi-forexrateapi-php/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)DependenciesVersions (2)Used By (0)

forexrateapi
============

[](#forexrateapi)

forexrateapi is the official PHP wrapper for ForexRateAPI.com. This allows you to quickly integrate our foreign exchange rate API and currency conversion API into your application. Check  documentation for more information.

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

[](#installation)

#### Composer

[](#composer)

```
$ composer require forexrateapi/forexrateapi-php

```

---

Usage
-----

[](#usage)

```
use ForexRateAPI\Client;

$client = new Client('SET_YOUR_API_KEY_HERE');
$result = $client->fetchLive('USD', ['AUD', 'CAD', 'GBP', 'JPY']);
```

---

Server Regions
--------------

[](#server-regions)

ForexRateAPI provides two regional endpoints. Choose the one closest to your servers for optimal performance.

RegionBase URLUnited States (default)`https://api.forexrateapi.com/v1`Europe`https://api-eu.forexrateapi.com/v1````
use ForexRateAPI\Client;

// Default (US)
$client = new Client('SET_YOUR_API_KEY_HERE');

// Europe
$client = new Client('SET_YOUR_API_KEY_HERE', Client::BASE_URL_EU);
```

---

setServer
---------

[](#setserver)

You can switch server regions at runtime using the `setServer` method:

```
$client = new Client('SET_YOUR_API_KEY_HERE');

// Switch to EU server
$client->setServer('eu');

// Switch back to US server
$client->setServer('us');
```

---

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

[](#documentation)

#### fetchSymbols()

[](#fetchsymbols)

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

[Link](https://forexrateapi.com/documentation#api_symbol)

---

#### fetchLive($base, $currencies, $math)

[](#fetchlivebase-currencies-math)

- `$base` &lt;[string](https://www.php.net/manual/en/language.types.string.php "String")&gt; Optional. Pass in a base currency, defaults to USD.
- `$currencies` &lt;[array](https://www.php.net/manual/en/language.types.array.php "Array")&lt;[string](https://www.php.net/manual/en/language.types.string.php "String")&gt;&gt; Optional. Pass in an array of currencies to return values for.
- `$math` &lt;[string](https://www.php.net/manual/en/language.types.string.php "String")&gt; Optional. Pass in a math expression to apply to the rates.

```
$client->fetchLive('USD', ['AUD', 'CAD', 'GBP', 'JPY']);
```

[Link](https://forexrateapi.com/documentation#api_realtime)

---

#### fetchHistorical($date, $base, $currencies)

[](#fetchhistoricaldate-base-currencies)

- `$date` &lt;[string](https://www.php.net/manual/en/language.types.string.php "String")&gt; Required. Pass in a string with format `YYYY-MM-DD`
- `$base` &lt;[string](https://www.php.net/manual/en/language.types.string.php "String")&gt; Optional. Pass in a base currency, defaults to USD.
- `$currencies` &lt;[array](https://www.php.net/manual/en/language.types.array.php "Array")&lt;[string](https://www.php.net/manual/en/language.types.string.php "String")&gt;&gt; Optional. Pass in an array of currencies to return values for.

```
$client->fetchHistorical('2024-02-05', 'USD', ['AUD', 'CAD', 'GBP', 'JPY']);
```

[Link](https://forexrateapi.com/documentation#api_historical)

---

#### hourly($base, $currency, $startDate, $endDate, $math, $dateType)

[](#hourlybase-currency-startdate-enddate-math-datetype)

- `$base` &lt;[string](https://www.php.net/manual/en/language.types.string.php "String")&gt; Optional. Pass in a base currency, defaults to USD.
- `$currency` &lt;[string](https://www.php.net/manual/en/language.types.string.php "String")&gt; Required. Specify currency you would like to get hourly rates for.
- `$startDate` &lt;[string](https://www.php.net/manual/en/language.types.string.php "String")&gt; Required. Specify the start date using the format `YYYY-MM-DD`.
- `$endDate` &lt;[string](https://www.php.net/manual/en/language.types.string.php "String")&gt; Required. Specify the end date using the format `YYYY-MM-DD`.
- `$math` &lt;[string](https://www.php.net/manual/en/language.types.string.php "String")&gt; Optional. Pass in a math expression to apply to the rates.
- `$dateType` &lt;[string](https://www.php.net/manual/en/language.types.string.php "String")&gt; Optional. Pass in a date type, overrides date parameters if passed in.

```
$client->hourly('USD', 'EUR', '2024-02-05', '2024-02-05', null, null);
```

[Link](https://forexrateapi.com/documentation#api_hourly)

---

#### ohlc($base, $currency, $date, $dateType)

[](#ohlcbase-currency-date-datetype)

- `$base` &lt;[string](https://www.php.net/manual/en/language.types.string.php "String")&gt; Optional. Pass in a base currency, defaults to USD.
- `$currency` &lt;[string](https://www.php.net/manual/en/language.types.string.php "String")&gt; Required. Specify currency you would like to get OHLC for.
- `$date` &lt;[string](https://www.php.net/manual/en/language.types.string.php "String")&gt; Required. Specify date to get OHLC for specific date using format `YYYY-MM-DD`.
- `$dateType` &lt;[string](https://www.php.net/manual/en/language.types.string.php "String")&gt; Optional. Pass in a date type, overrides date parameter if passed in.

```
$client->ohlc('USD', 'EUR', '2024-02-05', null);
```

[Link](https://forexrateapi.com/documentation#api_ohlc)

---

#### convert($from, $to, $amount, $date)

[](#convertfrom-to-amount-date)

- `$from` &lt;[string](https://www.php.net/manual/en/language.types.string.php "String")&gt; Optional. Pass in a base currency, defaults to USD.
- `$to` &lt;[string](https://www.php.net/manual/en/language.types.string.php "String")&gt; Required. Specify currency you would like to convert to.
- `$amount` &lt;[number](https://www.php.net/manual/en/language.types.float.php "Number")&gt; Required. The amount to convert.
- `$date` &lt;[string](https://www.php.net/manual/en/language.types.string.php "String")&gt; Optional. Specify date to use historical midpoint value for conversion with format `YYYY-MM-DD`. Otherwise, it will use live exchange rate date if value not passed in.

```
$client->convert('USD', 'EUR', 100, '2024-02-05');
```

[Link](https://forexrateapi.com/documentation#api_convert)

---

#### timeframe($startDate, $endDate, $base, $currencies)

[](#timeframestartdate-enddate-base-currencies)

- `$startDate` &lt;[string](https://www.php.net/manual/en/language.types.string.php "String")&gt; Required. Specify the start date of your timeframe using the format `YYYY-MM-DD`.
- `$endDate` &lt;[string](https://www.php.net/manual/en/language.types.string.php "String")&gt; Required. Specify the end date of your timeframe using the format `YYYY-MM-DD`.
- `$base` &lt;[string](https://www.php.net/manual/en/language.types.string.php "String")&gt; Optional. Pass in a base currency, defaults to USD.
- `$currencies` &lt;[array](https://www.php.net/manual/en/language.types.array.php "Array")&lt;[string](https://www.php.net/manual/en/language.types.string.php "String")&gt;&gt; Optional. Pass in an array of currencies to return values for.

```
$client->timeframe('2024-02-05', '2024-02-06', 'USD', ['AUD', 'CAD', 'GBP', 'JPY']);
```

[Link](https://forexrateapi.com/documentation#api_timeframe)

---

#### change($startDate, $endDate, $base, $currencies, $dateType)

[](#changestartdate-enddate-base-currencies-datetype)

- `$startDate` &lt;[string](https://www.php.net/manual/en/language.types.string.php "String")&gt; Required. Specify the start date of your timeframe using the format `YYYY-MM-DD`.
- `$endDate` &lt;[string](https://www.php.net/manual/en/language.types.string.php "String")&gt; Required. Specify the end date of your timeframe using the format `YYYY-MM-DD`.
- `$base` &lt;[string](https://www.php.net/manual/en/language.types.string.php "String")&gt; Optional. Pass in a base currency, defaults to USD.
- `$currencies` &lt;[array](https://www.php.net/manual/en/language.types.array.php "Array")&lt;[string](https://www.php.net/manual/en/language.types.string.php "String")&gt;&gt; Optional. Pass in an array of currencies to return values for.
- `$dateType` &lt;[string](https://www.php.net/manual/en/language.types.string.php "String")&gt; Optional. Pass in a date type, overrides date parameters if passed in.

```
$client->change('2024-02-05', '2024-02-06', 'USD', ['AUD', 'CAD', 'GBP', 'JPY'], null);
```

[Link](https://forexrateapi.com/documentation#api_change)

---

#### usage()

[](#usage-1)

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

[Link](https://forexrateapi.com/documentation#api_usage)

---

**[Official documentation](https://forexrateapi.com/documentation)**

---

FAQ
---

[](#faq)

- How do I get an API Key?

    Free API Keys are available [here](https://forexrateapi.com).
- I want more information

    Checkout our FAQs [here](https://forexrateapi.com/faq).

Support
-------

[](#support)

For support, get in touch using [this form](https://forexrateapi.com/contact).

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance84

Actively maintained with recent releases

Popularity1

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity34

Early-stage or recently created project

 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

Unknown

Total

1

Last Release

82d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/9d1b3ddf8405fae058402b5b1ef242ed19c71b6f8d4e0ee6ce2c9997d5a67ede?d=identicon)[forexrateapi](/maintainers/forexrateapi)

---

Top Contributors

[![forexrateapi](https://avatars.githubusercontent.com/u/123106351?v=4)](https://github.com/forexrateapi "forexrateapi (1 commits)")

---

Tags

apicurrencyconversionexchange ratesforexforeign exchange

### Embed Badge

![Health badge](/badges/forexrateapi-forexrateapi-php/health.svg)

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

###  Alternatives

[oneforge/forexquotes

Library to fetch and parse realtime Forex quotes and convert currencies

7212.5k](/packages/oneforge-forexquotes)[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)[orisai/object-mapper

Raw data mapping to validated objects

1133.5k2](/packages/orisai-object-mapper)

PHPackages © 2026

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