PHP code example of truncgil / finance

1. Go to this page and download the library: Download truncgil/finance 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/ */

    

truncgil / finance example snippets


return [
    'api_url' => 'https://api.truncgil.com/finance',
    'cache_key' => 'finance_data',
    'cache_duration' => 3600, // 1 hour
    'timeout' => 5, // 5 seconds
    'throw_exceptions' => true, // Throw exceptions
];

use Truncgil\Finance\Finance;

$finance = new Finance();
$data = $finance->getRates();

$currency = $finance->getCurrency('USD'); // Get USD currency data

$gold = $finance->getGold(); // Get all gold data

$crypto = $finance->getCryptoCurrency('BTC'); // Get BTC data

$item = $finance->get('Bitcoin'); // Get Bitcoin data

$updatedData = $finance->refreshData(); // Refresh data