PHP code example of ceytek-labs / tcmb-services-lite
1. Go to this page and download the library: Download ceytek-labs/tcmb-services-lite 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/ */
ceytek-labs / tcmb-services-lite example snippets
use CeytekLabs\TcmbServicesLite\TcmbExchangeRates;
// Displays the raw XML result from the API
echo TcmbExchangeRates::make()->response();
use CeytekLabs\TcmbServicesLite\TcmbExchangeRates;
// Converts the raw XML result from the API to JSON and displays it
echo TcmbExchangeRates::make()->jsonContent();
use CeytekLabs\TcmbServicesLite\TcmbExchangeRates;
use CeytekLabs\TcmbServicesLite\Enums\Format;
// Getting data in object format
$exchangeRatesObject = TcmbExchangeRates::make()->format(Format::Object)->content();
// Getting data in array format
$exchangeRatesArray = TcmbExchangeRates::make()->format(Format::Array)->content();
use CeytekLabs\TcmbServicesLite\TcmbExchangeRates;
use CeytekLabs\TcmbServicesLite\Enums\Format;
// Getting all exchange rates in object format
$currenciesObject = TcmbExchangeRates::make()->format(Format::Object)->currencies();
// Getting all exchange rates in array format
$currenciesArray = TcmbExchangeRates::make()->format(Format::Array)->currencies();
use CeytekLabs\TcmbServicesLite\TcmbExchangeRates;
use CeytekLabs\TcmbServicesLite\Enums\Format;
use CeytekLabs\TcmbServicesLite\Enums\Currency;
// For example, getting the Australian Dollar (AUD) rate
$australianDollar = TcmbExchangeRates::make()
->format(Format::Object)
->currency(Currency::AustralianDollar)
->find();
use CeytekLabs\TcmbServicesLite\TcmbExchangeRates;
use CeytekLabs\TcmbServicesLite\Enums\Format;
use CeytekLabs\TcmbServicesLite\Enums\Currency;
// Getting information for the USD currency
$exchangeRates = TcmbExchangeRates::make()
->format(Format::Object)
->currency(Currency::UnitedStatesDollar);
// Currency code
echo $exchangeRates->code(); // "USD"
// Turkish name
echo $exchangeRates->turkishName(); // "ABD DOLARI"
// English name
echo $exchangeRates->englishName(); // "US DOLLAR"
// Unit amount
echo $exchangeRates->unit(); // "1"
// Forex buying rate (The buying rate valid in international markets and digital transactions)
echo $exchangeRates->forexBuying();
// Forex selling rate (The selling rate valid in international markets and digital transactions)
echo $exchangeRates->forexSelling();
// Banknote buying rate (The buying rate valid in cash currency transactions)
echo $exchangeRates->banknoteBuying();
// Banknote selling rate (The selling rate valid in cash currency transactions)
echo $exchangeRates->banknoteSelling();
use CeytekLabs\TcmbServicesLite\TcmbExchangeRates;
use CeytekLabs\TcmbServicesLite\Enums\Format;
print_r(TcmbExchangeRates::make()->format(Format::Object)->content());
use CeytekLabs\TcmbServicesLite\TcmbExchangeRates;
use CeytekLabs\TcmbServicesLite\Enums\Format;
print_r(TcmbExchangeRates::make()->format(Format::Array)->content());