PHPackages                             abgeo/nbg-currency - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. abgeo/nbg-currency

ActiveLibrary[API Development](/categories/api)

abgeo/nbg-currency
==================

Library for getting data from National Bank of Georgia (NBG)'s API.

v2.0.0(6y ago)1442↓100%1[1 PRs](https://github.com/ABGEO/nbg-currency/pulls)MITPHPCI failing

Since Jul 17Pushed 5y agoCompare

[ Source](https://github.com/ABGEO/nbg-currency)[ Packagist](https://packagist.org/packages/abgeo/nbg-currency)[ Docs](https://github.com/ABGEO07/nbg-currency)[ RSS](/packages/abgeo-nbg-currency/feed)WikiDiscussions 2.x Synced 1mo ago

READMEChangelog (6)Dependencies (1)Versions (9)Used By (0)

nbg-currency
============

[](#nbg-currency)

PHP Library for getting data from [National Bank of Georgia (NBG)'s API](http://nbg.ge/api.html).

- Library maintainer [ABGEO](https://abgeo.dev)
- Library on [GitHub](https://github.com/ABGEO07/nbg-currency)
- Library on [Packagist](https://packagist.org/packages/abgeo/nbg-currency)

[![GitHub license](https://camo.githubusercontent.com/9f9e8472547cb0dd25affc328e026b227caef154ec256a7c4a1bad61be5a1e6b/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f414247454f30372f6e62672d63757272656e63792e737667)](https://github.com/ABGEO07/nbg-currency/blob/master/LICENSE)

[![GitHub release](https://camo.githubusercontent.com/80a68d943038fd1e7ee3eccf7c7030333d4eedc5e69fc90a0b82c8254a0400d6/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f414247454f30372f6e62672d63757272656e63792e737667)](https://github.com/ABGEO07/nbg-currency/releases)

[![Packagist Version](https://camo.githubusercontent.com/4ec6f7101b9f9638134eb38cc046681b8f9d9df139b36ff3bd403ac149840ccb/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f616267656f2f6e62672d63757272656e63792e737667 "Packagist Version")](https://packagist.org/packages/abgeo/nbg-currency "Packagist Version")

[![Build Status](https://camo.githubusercontent.com/761f260a00b49d111134ac29e713c233c8c3f3a15c06c8e0418e76025fb5b6f6/68747470733a2f2f7472617669732d63692e636f6d2f414247454f30372f6e62672d63757272656e63792e7376673f6272616e63683d6d6173746572)](https://travis-ci.com/ABGEO07/nbg-currency)

---

**See documentation generated by [phpDocumentor](https://www.phpdoc.org/) in [docs/](docs) folder.**

Installation
------------

[](#installation)

You can install this library with [Composer](https://getcomposer.org/):

- `composer require abgeo/nbg-currency`

Usage
-----

[](#usage)

Include composer autoloader in your main file (Ex.: index.php)

- `require_once __DIR__.'/../vendor/autoload.php';`

Import Classes:

- `use ABGEO\NBG\Currency;`
- `use ABGEO\NBG\Helper\CurrencyCodes;`

Now you can create new `Currency` Class object ex. for `USD` currency:

- `$USD = new Currency(CurrencyCodes::USD);`

The `Currency` class constructor takes a single argument - the Currency Code. You can pass it manually (ISO 4217) or using `ABGEO\NBG\Helper\CurrencyCodes` class constants:

```
AED, AMD, AUD, AZN, BGN, BYR, CAD, CHF, CNY, CZK, DKK, EEK, EGP, EUR,
GBP, HKD, HUF, ILS, INR, IRR, ISK, JPY, KGS, KWD, KZT, LTL, LVL, MDL,
NOK, NZD, PLN, RON, RSD, RUB, SEK, SGD, TJS, TMT, TRY, UAH, USD, UZS.

```

After creating a class object, we can get currency data.
The API gives us:

- Currency Amount;
- Currency Description;
- Currency Change value;
- Currency Change rate (-1 - decreased; 0 - unchanged; 1 - increased);
- Currency Date;

### Public methods

[](#public-methods)

- `getCurrency()` - Get Currency Amount;
- `getDescription()` - Get Currency Description;
- `getChange()` - Currency Change value;
- `getRate()` - Get Currency Change rate;
- `getDate()` - Get Currency Date;

Examples
--------

[](#examples)

### Example for USD

[](#example-for-usd)

```
...
echo "Currency: \t{$USD->getCurrency()}\n";
echo "Description: \t{$USD->getDescription()}\n";
echo "Change: \t{$USD->getChange()}\n";
echo "Change Rate: \t{$USD->getRate()}\n";
echo "Date: \t\t{$USD->getDate()->format('m/d/Y')}\n";
...
```

### Full example with USD and EUR

[](#full-example-with-usd-and-eur)

```
