centrex/laravel-open-exchange-rates
Composer 安装命令:
composer require centrex/laravel-open-exchange-rates
包简介
This is my package laravel-open-exchange-rates
README 文档
README
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.
统计信息
- 总下载量: 2.89k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-03-14