Currency API Wrapper for API
, (*1)
Table of contents
Installation
Just run this simple command through your command line, (*2)
composer require gufy/currency:~1
Or update manually your composer.json
, (*3)
{
"require":{
...
"gufy/currency":"~1"
...
}
}
Usage
This package currently only support OpenExchangeRates as the main API., (*4)
Getting latest currency rates
<?php
include 'vendor/autoload.php';
use Gufy\Currency\OpenExchange;
$api = new OpenExchange("your-app-id");
$rates = $api->rates();
Getting currency rates based on date
<?php
include 'vendor/autoload.php';
use Gufy\Currency\OpenExchange;
$date = "2016-06-06";
$api = new OpenExchange("your-app-id");
$rates = $api->rates("USD", $date);
Convert value to some currency
<?php
include 'vendor/autoload.php';
use Gufy\Currency\OpenExchange;
$api = new OpenExchange("your-app-id");
$value = 10;
$base = "USD";
$target = "IDR";
$rates = $api->convert($value, $base, $target);
Get all available currencies
<?php
include 'vendor/autoload.php';
use Gufy\Currency\OpenExchange;
$api = new OpenExchange("your-app-id");
$rates = $api->currencies();