fastforex/fastforex-php-client
Composer 安装命令:
composer require fastforex/fastforex-php-client
包简介
PHP client for fastFOREX.io Currency Exchange Rate API
README 文档
README
You'll need an API key to use the API client. Get a Free Trial API Key.
- 160+ Currencies
- 500+ Crypto Currencies
- 2,300+ FX trading pairs
- Up 55 years of historical data
Installation
With Composer:
composer require fastforex/fastforex-php-client
Quick Start
Set the API key once in your bootstrap code, or in the constructor:
\FastForex\Client::setApiKey('YOUR_API_KEY');
new \FastForex\Client('YOUR_API_KEY');
Fetch all currencies, with USD base:
$response = (new FastForex\Client())->fetchAll('USD'); print_r($response);
stdClass Object
(
[base] => USD
[results] => stdClass Object
(
[AED] => 3.67246
[AFN] => 77.19882
[ALL] => 101.68772
...
)
[updated] => 2021-02-15 22:13:51
[ms] => 5
)
More Examples
Fetch GBP, with USD base:
$response = (new FastForex\Client())->fetchOne('USD', 'GBP'); echo $response->result->GBP;
Fetch several currencies with USD base:
$response = (new FastForex\Client())->fetchMulti('USD', ['GBP', 'EUR', 'CHF']);
Convert 200 USD to GBP:
$response = (new FastForex\Client())->convert('USD', 'GBP', 199.99);
Fetch a list of supported currencies
$response = (new FastForex\Client())->currencies();
Fetch recent API usage
$response = (new FastForex\Client())->usage();
Get all the historical exchange rates for 1st April 2021, with USD base:
$response = (new FastForex\Client())->historical(new \DateTime('2021-04-01'), 'USD');
Get a subset of historical exchange rates for 1st April 2021, with USD base:
$response = (new FastForex\Client())->historical(new \DateTime('2021-04-01'), 'USD', ['EUR', 'GBP', 'CHF']);
Get a 7-day time-series dataset for EUR to CHF
$response = (new FastForex\Client())->timeSeries( new \DateTime('2021-04-01'), new \DateTime('2021-04-07'), 'EUR', 'CHF' );
Error Handling
We throw the following Exceptions:
\InvalidArgumentException
Usually when input parameters to the client are wrong
\FastForex\Exception\APIException
When there is problem making the API call, or when there is an error response from the server.
We include the HTTP response code and error message wherever possible:
try { $response = (new FastForex\Client('INVALID_API_KEY'))->fetchAll('USD'); } catch (\FastForex\Exception\APIException $exception) { echo $exception->getMessage(), PHP_EOL; }
Free Trial
Our 7-day free trial API keys are unrestricted. All features and full API quota.
API Documentation
OpenAPI Spec
fastforex/fastforex-php-client 适用场景与选型建议
fastforex/fastforex-php-client 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 12.96k 次下载、GitHub Stars 达 1, 最近一次更新时间为 2021 年 02 月 15 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 fastforex/fastforex-php-client 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 fastforex/fastforex-php-client 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 12.96k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2021-02-15