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/fxuse 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;
}- 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: falseif you listed an IPv6 address. When the API refuses an address,FxException::$seenIptells 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
$ttlseconds (default 120) inside oneClientobject. For a shared cache across requests, put your own (Redis, APCu, LaravelCache::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