PHP code example of centrex / laravel-open-exchange-rates

1. Go to this page and download the library: Download centrex/laravel-open-exchange-rates library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

centrex / laravel-open-exchange-rates example snippets


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();