Skip to content
netarzPublic

About

PHP client for the NetArz FX API: Iranian Toman exchange rates (USD, EUR, AED, TRY…)

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 

Repository files navigation

netarz/fx

PHP client for the NetArz FX API: Tehran open-market exchange rates in Iranian Toman for USD, EUR, AED, TRY, GBP and the other currencies on the NetArz rate board, with buy/sell prices, a converter and, on the Pro plan, history and the daily archive.

PHP 8.1+, ext-curl. No other dependencies.

composer config repositories.netarz-fx vcs https://github.com/netarz/fx-php
composer require netarz/fx:^0.1
# Packagist release coming soon: composer require netarz/fx
use NetArz\Fx\Client;
use NetArz\Fx\FxException;

$fx = new Client(getenv('NETARZ_FX_KEY'));   // create a free key at https://netarz.ir/fx

$usd = $fx->rate('USD');
echo $usd['buy'], ' / ', $usd['sell'];         // Toman

echo $fx->convert('USD', 'IRT', 250)['result']; // 250 dollars in Toman

try {
    $fx->history('USD', ['range' => '30d', 'interval' => '1d']); // Pro plan
} catch (FxException $e) {
    echo $e->status, ' ', $e->errorCode, ' ', $e->seenIp;
}

Things to know

  • Keys are locked. A server-side key answers only from the IP addresses you list on the app. The client connects over IPv4 by default so the source address matches what you listed; pass ipv4: false if you listed an IPv6 address. When the API refuses an address, FxException::$seenIp tells you which one it saw.
  • Free and Pro. The free plan needs only an account and returns delayed rates. Pro returns live rates and unlocks history, OHLC, stats and the archive. See plans.
  • Cache. GET answers are reused for $ttl seconds (default 120) inside one Client object. For a shared cache across requests, put your own (Redis, APCu, Laravel Cache::remember) in front of it.
  • Laravel and WordPress: see fx-api-examples/laravel and the WordPress plugin.
  • Rates are for information; NetArz does not buy or sell these currencies.

Docs: netarz.ir/docs/fx · Reference: netarz.ir/docs/fx/reference

فارسی

کتابخانهٔ PHP برای API نرخ ارز نِت اَرز: نرخ خرید و فروش دلار، یورو، درهم، لیر و ارزهای دیگر به تومان، همراه مبدل ارز. فقط افزونهٔ curl را لازم دارد. کلید رایگان را از پنل API نرخ ارز بگیرید. کلید سمت سرور فقط از IP‌هایی که در پنل ثبت کرده‌اید جواب می‌گیرد.

MIT License · NetArz

About

PHP client for the NetArz FX API: Iranian Toman exchange rates (USD, EUR, AED, TRY…)

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages