Skip to main content

NBP SDK

Python package PyPI version

SDK umozliwijące komunikację z API Narodowego Banku Polskiego.

Instalacja

pip install nbp_sdk

Przykładowe uzycie

from nbp_sdk.client import NBPApiClient
from nbp_sdk.types import CurrencyType

api = NBPApiClient() 

currency = api.get_currency_rate_from_today(CurrencyType.EUR)
print(currency)

start_date = datetime(2024, 3, 11)
end_date = datetime(2024, 3, 14) 
currencies = api.get_currency_rate_from_start_date_to_end_date(CurrencyType.EUR, start_date, end_date)
print(currencies)
from nbp_sdk.client import NBPApiClient

api = NBPApiClient() 

gold = api.get_gold_rate_currently_valid()
print(gold)

date = datetime(2024, 3, 14)
gold = api.get_gold_rate_from_working_day_before_date(date)
print(gold)

start_date = datetime(2024, 3, 11)
end_date = datetime(2024, 3, 14) 
golds = api.get_gold_rate_from_start_date_to_end_date(start_date, end_date)
print(golds)

W razie wątpliwości przeczytaj README do końca i rzuć okiem na testy.

Dokumentacja

Dostępne metody


get_currency_rate_currently_valid

Aktualnie obowiązujący kurs waluty w PLN

get_currency_rate_from_today

Kurs waluty w PLN opublikowany w dniu dzisiejszym (albo brak danych)

get_currency_rate_from_date

Kurs waluty opublikowany w dniu {date} (albo brak danych)

get_currency_rate_from_working_day_before_date

Kurs waluty opublikowany w dniu roboczym poprzedzającym podaną datę {date}

Jeśli podasz datę której dzień tygodnia wypada w poniedziałek, kurs zostanie pobrany z piątku. Jeśli podasz datę której dzień tygodnia wypada w środę, kurs zostanie pobrany z wtorku.

get_currency_rate_from_start_date_to_end_date

Seria tabel kursów typu opublikowanych w zakresie dat od {start_date} do {end_date} (albo brak danych)


get_gold_rate_currently_valid

Aktualnie obowiązująca cena złota

get_gold_rate_from_today

Cena złota opublikowana w dniu dzisiejszym (albo brak danych)

get_gold_rate_from_date

Cena złota opublikowana w dniu {date} (albo brak danych)

get_gold_rate_from_working_day_before_date

Cena złota opublikowana w dniu roboczym poprzedzającym podaną datę {date}

Jeśli podasz datę której dzień tygodnia wypada w poniedziałek, kurs zostanie pobrany z piątku. Jeśli podasz datę której dzień tygodnia wypada w środę, kurs zostanie pobrany z wtorku.

get_gold_rate_from_start_date_to_end_date

Seria tabel kursów typu opublikowanych w zakresie dat od {start_date} do {end_date} (albo brak danych)

Zwracane modele

class Currency:
    type: CurrencyType
    # przeliczony kurs średni waluty
    average_rate: Decimal
    table_no: str
    # data publikacji
    effective_date: datetime


class Gold:
    # wyliczona w NBP cena 1 g złota (w próbie 1000)
    rate_per_1g: Decimal
    # data publikacji
    effective_date: datetime

Kontakt

Jeśli będzie Wam czegoś brakowało to dodajcie swoje Issue albo PR, które są oczywiście mile widziane.

Metadata

Release files for nbp-sdk 0.1.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for nbp-sdk 0.1.6
File Size Uploaded Provenance Actions
nbp_sdk-0.1.6.tar.gz 6.9 kB Without provenance Details for nbp_sdk-0.1.6.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for nbp-sdk 0.1.6
File Interpreter ABI Platform Actions
nbp_sdk-0.1.6-py3-none-any.whl Python 3 none any Details for nbp_sdk-0.1.6-py3-none-any.whl

Total release size: 14.1 kB

Release files / nbp_sdk-0.1.6.tar.gz

Download URL nbp_sdk-0.1.6.tar.gz
Size 6.9 kB
Tags Source
SHA-256 checksum
How to use checksums
800aff3068af5c38faf4920f083e6ee409d4261955cf3270318aec3e1c057be7
BLAKE2b-256 checksum
How to use checksums
50fa9f599d60960a0dc91f8c032884994bd77aa6c8d90857920788900f6a483e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.12.7

Release files / nbp_sdk-0.1.6-py3-none-any.whl

Download URL nbp_sdk-0.1.6-py3-none-any.whl
Size 7.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
211c2ce7ba5cae91c65a9522a5f25ab5016909fe752f5329cf0940757378003f
BLAKE2b-256 checksum
How to use checksums
663eefd41cac753fe5df31187759d2a69cd914774e7d1261f0cb81f33d377e31
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.12.7

Security for nbp-sdk 0.1.6

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page