Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/adamale/nbpfetch
PHP library that helps to fetch data from NBP API.
https://github.com/adamale/nbpfetch
api-client composer currency-exchange-rates currency-rates exchange-rates gold-price mit nbp nbp-api php php-7 php-library travis-ci
Last synced: about 1 month ago
JSON representation
PHP library that helps to fetch data from NBP API.
- Host: GitHub
- URL: https://github.com/adamale/nbpfetch
- Owner: adamale
- License: mit
- Created: 2019-07-28T10:47:16.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2019-09-08T09:03:01.000Z (about 5 years ago)
- Last Synced: 2024-04-23T17:33:41.166Z (7 months ago)
- Topics: api-client, composer, currency-exchange-rates, currency-rates, exchange-rates, gold-price, mit, nbp, nbp-api, php, php-7, php-library, travis-ci
- Language: PHP
- Homepage:
- Size: 164 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# NBPFetch [![Build Status](https://travis-ci.org/adamale/NBPFetch.svg?branch=master)](https://travis-ci.org/adamale/NBPFetch)
PHP library that helps to fetch data from NBP API - http://api.nbp.pl/en.html.
It allows you to fetch currency rates, exchange rate tables and gold prices.## Requirements
PHP 7.2 or above.## Installation
a) with Composer:
``` bash
composer require adamale/nbpfetch
```
b) without Composer:
include [Composer File Loader](https://github.com/Wilkins/composer-file-loader) in your project to autoload all the necessary classes.## Usage
### Currency rate
```php
currencyRate();/**
* Currency rate examples.
* Available methods are: current(string $currency), today(string $currency)
* byDate(string $currency, string $date), byDateRange(string $currency, string $from, string $to)
* and last(string $currency, int count).
*/
try {
$currentCurrencyRate = $NBPFetchCurrencyRate->current("EUR");
$todayCurrencyRate = $NBPFetchCurrencyRate->current("EUR");
$givenDateCurrencyRate = $NBPFetchCurrencyRate->byDate("EUR", "2019-08-28");
$givenDateRangeCurrencyRates = $NBPFetchCurrencyRate->byDateRange("EUR", "2019-08-01", "2019-08-31");
$last10CurrencyRates = $NBPFetchCurrencyRate->last("EUR", 10);
} catch (Exception $e) {
}
```### Exchange rate table
```php
exchangeRateTable();/**
* Exchange rate table examples.
* Available methods are: current(string $table), today(string $table),
* byDate(string $table, string $date), byDateRange(string $table, string $from, string $to)
* and last(string $table, int count)
*/
try {
$currentExchangeRateTable = $NBPFetchExchangeRateTable->current("A");
$todayExchangeRateTable = $NBPFetchExchangeRateTable->today("A");
$givenDateExchangeRateTable = $NBPFetchExchangeRateTable->byDate("A", "2019-08-28");
$givenDateRangeExchangeRateTables = $NBPFetchExchangeRateTable->byDateRange("A", "2019-08-01", "2019-08-31");
$last10ExchangeRateTables = $NBPFetchExchangeRateTable->last("A", 10);
} catch (Exception $e) {
}
```### Gold price
```php
goldPrice();/**
* Gold price examples.
* Available methods are: current(), today(), byDate(string $date),
* byDateRange(string $from, string $to) and last(int count)
*/
try {
$currentGoldPrice = $NBPFetchGoldPrice->current();
$todayGoldPrice = $NBPFetchGoldPrice->today();
$givenDateGoldPrice = $NBPFetchGoldPrice->byDate("2019-08-28");
$givenDateRangeGoldPrices = $NBPFetchGoldPrice->byDateRange("2019-08-01", "2019-08-31");
$last10GoldPrices = $NBPFetchGoldPrice->last(10);
} catch (Exception $e) {
}
```## About
### Author
Adam Aleksak### License
NBPFetch is licensed under the MIT License - see the `LICENSE` file for the details.