Looking to hire Laravel developers? Try LaraJobs

laravel-open-exchange-rates maintained by centrex

Description
This is my package laravel-open-exchange-rates
Author
Last update
2026/05/01 19:28 (dev-main)
License
Downloads
2 701

Comments
comments powered by Disqus

Laravel Open Exchange Rates

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

Laravel client for the Open Exchange Rates API. Provides access to latest rates, historical rates, currency conversion, OHLC data, time-series, and account usage.

Installation

composer require centrex/laravel-open-exchange-rates
php artisan vendor:publish --tag="laravel-open-exchange-rates-config"

Add your App ID to .env:

OPEN_EXCHANGE_RATES_APP_ID=your_app_id_here

Usage

use Centrex\LaravelOpenExchangeRates\Facades\OpenExchangeRates;

// Latest rates (all currencies)
$rates = OpenExchangeRates::latest();

// Latest rates for specific currencies
$rates = OpenExchangeRates::latest('USD,EUR,BDT,GBP');

// Historical rates for a date
$rates = OpenExchangeRates::historical('2024-01-01');
$rates = OpenExchangeRates::historical('2024-01-01', 'USD,EUR');

// Convert a value between currencies
$result = OpenExchangeRates::convert(100, 'USD', 'BDT');

// Full list of available currencies
$currencies = OpenExchangeRates::currencies();
$currencies = OpenExchangeRates::currencies(showAlternative: '1');

// Time-series rates between two dates
$series = OpenExchangeRates::timeSeries('2024-01-01', '2024-01-31', 'USD,EUR');

// OHLC (Open, High, Low, Close) for a period
// Allowed periods: 1m, 5m, 15m, 30m, 1h, 12h, 1d, 1w, 1mo
$ohlc = OpenExchangeRates::ohlc('2024-01-01T00:00:00Z', '1d', 'USD,EUR');

// Account usage stats
$usage = OpenExchangeRates::usage();

All methods return a decoded array. An OpenExchangeRatesResponseException is thrown on API errors.

Testing

composer test        # full suite
composer test:unit   # pest only
composer test:types  # phpstan
composer lint        # pint

Changelog

Please see CHANGELOG for more information on what has changed recently.

Credits

License

The MIT License (MIT). Please see License File for more information.