PHPackages                             kreyu/nbp-web-api - 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. kreyu/nbp-web-api

ActiveLibrary[API Development](/categories/api)

kreyu/nbp-web-api
=================

NBP Web API client for PHP.

v1.1.0(3y ago)36.9k↓50%2MITPHPPHP ^7.2 || ^8.0

Since Oct 23Pushed 3y ago1 watchersCompare

[ Source](https://github.com/Kreyu/nbp-web-api-php)[ Packagist](https://packagist.org/packages/kreyu/nbp-web-api)[ RSS](/packages/kreyu-nbp-web-api/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (3)Dependencies (13)Versions (4)Used By (0)

NBP Web API Client
==================

[](#nbp-web-api-client)

[![Latest Stable Version](https://camo.githubusercontent.com/ca73a0c272fe311f23ee0c30dbd99848156d1e17d8fb1fe70213239eedc1cf67/68747470733a2f2f706f7365722e707567782e6f72672f6b726579752f6e62702d7765622d6170692f76657273696f6e)](https://packagist.org/packages/kreyu/nbp-web-api)[![Build Status](https://camo.githubusercontent.com/75d61116243fec2647165f9e43447892b7ad72b9ae94bacb1437cd56868523d4/68747470733a2f2f6170692e7472617669732d63692e636f6d2f4b726579752f6e62702d7765622d6170692d7068702e737667)](https://travis-ci.org/Kreyu/nbp-web-api-php)

Simple and fluent interface to retrieve data from [NBP Web API](http://api.nbp.pl/).
This library structure is strongly inspired by [knplabs/github-api](https://github.com/KnpLabs/php-github-api) package.

### Installation

[](#installation)

This package is decoupled from any HTTP client thanks to the [HTTPlug](https://httplug.io/).
Requires packages that provide [http-client-implementation](https://packagist.org/providers/psr/http-client-implementation) and [psr/http-factory-implementation](https://packagist.org/providers/psr/http-factory-implementation).
For more information visit [HTTPlug for library users](https://docs.php-http.org/en/latest/httplug/users.html).

```
$ composer require kreyu/nbp-web-api

```

### Usage

[](#usage)

```
use Kreyu\NBPWebApi\Client;
use Kreyu\NBPWebApi\Api\ExchangeRates;

$client = new Client();

// Example call
$client->exchangeRates(ExchangeRates::TABLE_TYPE_A)->forCurrency('EUR')->latest(5);
```

#### Changing content type

[](#changing-content-type)

If you wish to retrieve responses in XML format rather than JSON, you can change it in the client:

```
use Kreyu\NBPWebApi\Client;
use Kreyu\NBPWebApi\ClientInterface;

$client = new Client();
$client->setContentType(ClientInterface::CONTENT_TYPE_XML);
```

#### Providing HTTP client and factories

[](#providing-http-client-and-factories)

By default, the HTTP client builder uses HTTP client and factories provided by the [discovery](https://github.com/php-http/discovery).
If you have to provide specific [PSR-18](https://www.php-fig.org/psr/psr-18/) compliant client or any [PSR-17](https://www.php-fig.org/psr/psr-17/) factory, you can pass them to the HTTP client builder:

```
use Kreyu\NBPWebApi\Client;
use Kreyu\NBPWebApi\Http\ClientBuilder as HttpClientBuilder;

/**
 * @var $client         Psr\Http\Client\ClientInterface
 * @var $requestFactory Psr\Http\Message\RequestFactoryInterface
 * @var $streamFactory  Psr\Http\Message\StreamFactoryInterface
 * @var $uriFactory     Psr\Http\Message\UriFactoryInterface
 */

$builder = new HttpClientBuilder(
    $client,
    $requestFactory,
    $streamFactory,
    $uriFactory
);

$client = new Client($builder);
```

#### Caching

[](#caching)

To use caching mechanism, provide any [PSR-6](https://www.php-fig.org/psr/psr-6/) compliant item pool to the HTTP client builder:

```
use Kreyu\NBPWebApi\Client;
use Kreyu\NBPWebApi\Http\ClientBuilder as HttpClientBuilder;

/** @var $pool Psr\Cache\CacheItemPoolInterface */

$builder = new HttpClientBuilder();
$builder->setCache($pool);

$client = new Client($builder);
```

#### Using HTTPlug plugins

[](#using-httplug-plugins)

You can provide any [HTTPlug plugin](http://docs.php-http.org/en/latest/plugins/) to the HTTP client builder:

```
use Kreyu\NBPWebApi\Client;
use Kreyu\NBPWebApi\Http\ClientBuilder as HttpClientBuilder;

/** @var $plugin Http\Client\Common\Plugin */

$builder = new HttpClientBuilder();
$builder->addPlugin($plugin);

$client = new Client($builder);
```

###  Health Score

33

—

LowBetter than 75% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity27

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity61

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~419 days

Total

3

Last Release

1193d ago

PHP version history (2 changes)v1.0.0PHP ^7.2

v1.1.0PHP ^7.2 || ^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/bb31130871cea8f2bfe456cc54856b0a965791e3034bc1e929c027fba7e5edf4?d=identicon)[Kreyu](/maintainers/Kreyu)

---

Top Contributors

[![Kreyu](https://avatars.githubusercontent.com/u/24738141?v=4)](https://github.com/Kreyu "Kreyu (20 commits)")

---

Tags

httplugnbpphppsrapiclientnbp

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/kreyu-nbp-web-api/health.svg)

```
[![Health](https://phpackages.com/badges/kreyu-nbp-web-api/health.svg)](https://phpackages.com/packages/kreyu-nbp-web-api)
```

###  Alternatives

[phpro/http-tools

HTTP tools for developing more consistent HTTP implementations.

28137.8k](/packages/phpro-http-tools)[openai-php/client

OpenAI PHP is a supercharged PHP API client that allows you to interact with the Open AI API

5.8k22.6M232](/packages/openai-php-client)[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.4k5.6M651](/packages/sylius-sylius)[knplabs/github-api

GitHub API v3 client

2.2k15.8M187](/packages/knplabs-github-api)[m4tthumphrey/php-gitlab-api

GitLab API v4 client for PHP

9485.4M64](/packages/m4tthumphrey-php-gitlab-api)[jolicode/slack-php-api

An up to date PHP client for Slack's API

2534.4M12](/packages/jolicode-slack-php-api)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
