Skip to main content

ua-banktools

A collection of Python tools and APIs for interacting with Ukrainian banks

Banks currently supported

  • PrivatBank (legal entities only)
  • monobank (public and personal)
  • National Bank of Ukraine (public exchange rates)

Features

  • Object-oriented as much as possible, with IBANs validated by schwifty, timestamps automatically parsed into datetime objects, and known categorical values parsed into enums.
  • Multiple banks in one package.
  • Every response model survives model_dump_json(), so results can be cached or forwarded without re-flattening.
  • Statement assembly is built in: PrivatBank pagination and Monobank's 31-day window limit are handled for you.

Shared client behaviour

Every client accepts an optional session. Pass your own httpx.Client to set a different timeout, add headers, install event hooks, or route through a proxy:

import httpx

from ua_banktools.banks import MonobankPersonalClient

session = httpx.Client(
    headers={"Authorization": "Bearer proxy-secret"},
    timeout=httpx.Timeout(90.0),
)
client = MonobankPersonalClient("your-token", base_url="https://gateway.example/mono/", session=session)

Credentials are sent per request rather than written into the session, so one session can safely be shared between clients for different banks.

Without a session the default is httpx.Timeout(30.0, connect=10.0). It is bounded on purpose — an unbounded timeout lets a hung upstream block the caller indefinitely, which in an async consumer means a stalled event loop.

Monobank and the PrivatBank corporate API describe their failures with documented JSON bodies, and those are returned as values (MonobankErrorResponse, PrivatbankErrorResponse) for the caller to branch on. An HTTP error carrying anything else — a proxy rejecting the request, an HTML error page, a gateway timeout — raises BankTransportError instead of failing as a confusing ValidationError:

from ua_banktools.banks import BankTransportError

Monobank Open API

from datetime import datetime

from ua_banktools.banks import MonobankPersonalClient, MonobankPublicClient

public_client = MonobankPublicClient()
client = MonobankPersonalClient("your-token")
public_client.get_currency_rates()
public_client.get_bank_sync()
client.get_client_info()
client.set_webhook("https://example.com/monobank-webhook")
client.get_statement("account-id", datetime(2026, 1, 1))

# Ranges longer than 31 days need to be split; get_full_statement does it for you.
client.get_full_statement("account-id", datetime(2026, 1, 1), datetime(2026, 6, 30))

get_statement sends exactly one request and so is capped by Monobank at 31 days plus one hour. get_full_statement splits a longer span into consecutive windows and concatenates them.

The split is a separate method rather than the default because the cost is not visible at the call site: each window is another request against Monobank's limit of one statement request per 60 seconds, so a year-long range is twelve windows — and behind a pacing proxy, twelve minutes of waiting. If any window fails, the error is returned and earlier windows are discarded; a partial statement mistaken for a complete one is worse than none.

The default base URL is https://api.monobank.ua/. It can be overridden for an egress gateway; include any route prefix required by the gateway:

client = MonobankPersonalClient(
    "your-token",
    base_url="https://mono-egress.example.com/mono/",
)

Tests

Run the mocked Monobank tests with just test mono, or all available tests with just test. An explicitly opted-in, read-only smoke test is also available:

# .env (do not commit this file!)
MONO_TOKEN=your-personal-token

just test mono-live

The live test makes one client-info request and one statement request for the most recent hour. It is skipped by normal test runs and never changes webhook configuration.

PrivatBank Autoclient API

from datetime import date
from decimal import Decimal

from schwifty import IBAN

from ua_banktools.banks import ExchangeRateType, PBCorporateClient, PBPublicClient

client = PBCorporateClient("your-token")
public_client = PBPublicClient()
account = IBAN("UA943052990000026100050001037")

cash_rates = public_client.get_exchange_rates()
non_cash_rates = public_client.get_exchange_rates(ExchangeRateType.NON_CASH)
historical_rates = public_client.get_historical_exchange_rates(date(2026, 7, 1))
balances = client.get_balance(account, date(2026, 7, 1), limit=100)
transactions = client.get_transactions(
    account,
    date(2026, 7, 1),
    date(2026, 7, 10),
)
payment = client.create_payment(
    payer_acct=account,
    recipient_acct=IBAN("UA323052990000026000000000000"),
    recipient_nceo="14360570",
    payee_name="Counterparty",
    amount=Decimal("1.20"),
    designation="Payment purpose",
    document_number="42",
)

# Delete a created payment while it is still eligible for deletion.
client.delete_payment(payment.payment_ref)

Pass None as the statement account to request all active accounts. The optional client_id constructor argument remains available for legacy integrations.

get_balance and get_transactions return one page each. If exist_next_page is true, pass the response's next_page_id back as follow_id to fetch the next. To walk a whole statement instead, use the get_all_* variants:

all_transactions = client.get_all_transactions(account, date(2026, 7, 1), date(2026, 7, 31))
all_balances = client.get_all_balances(account, date(2026, 7, 1))

These follow pagination to the end and return a flat list. They refuse to loop on a repeated next_page_id, reject a malformed one before echoing it upstream, and stop at max_pages (100 by default).

Run the mocked PrivatBank tests with just test pb.

National Bank of Ukraine Open Data API

from datetime import date

from iso4217 import Currency

from ua_banktools.banks import NBUPublicClient, NBUSortOrder

client = NBUPublicClient()

current_rates = client.get_exchange_rates()
eur_rate = client.get_exchange_rate(Currency.EUR, date(2026, 7, 1))
usd_history = client.get_exchange_rate_history(
    "USD",
    date(2026, 7, 1),
    date(2026, 7, 10),
    order=NBUSortOrder.DESC,
)

Currency and investment-metal codes are case-insensitive and normalized to iso4217.Currency objects. Plain strings such as "EUR" are also accepted by client methods. Rates are parsed as Decimal values and NBU dates as date values. The API is public and does not require authentication. Run its mocked tests with just test nbu.

Metadata

Release files for ua-banktools 0.4.0

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

Source distribution (sdist)

Source distribution for ua-banktools 0.4.0
File Size Uploaded Provenance Actions
ua_banktools-0.4.0.tar.gz 105.9 kB With provenance Details for ua_banktools-0.4.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for ua-banktools 0.4.0
File Interpreter ABI Platform Actions
ua_banktools-0.4.0-py3-none-any.whl Python 3 none any Details for ua_banktools-0.4.0-py3-none-any.whl

Total release size: 128.5 kB

Release files / ua_banktools-0.4.0.tar.gz

Download URL ua_banktools-0.4.0.tar.gz
Size 105.9 kB
Tags Source
SHA-256 checksum
How to use checksums
b4608a12e228275c144b23e870e45c6a2da498b12ec3b612be97bbe750b3f185
BLAKE2b-256 checksum
How to use checksums
39189e1a6c9445125c989a78789cf06fc5ecf24a4a6186f79aaef959264261ed
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.6 {"installer":{"name":"uv","version":"0.13.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 30, 2026.

Transparency log

Release files / ua_banktools-0.4.0-py3-none-any.whl

Download URL ua_banktools-0.4.0-py3-none-any.whl
Size 22.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2d1e40890e207711e999e0a3de5a8f28ac7728b47fd88e54064ea570e2780d0a
BLAKE2b-256 checksum
How to use checksums
8a80cc34e723d4e491a08469ae69f1dad86b4d46d7c8a8a07efcf136233cec62
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.6 {"installer":{"name":"uv","version":"0.13.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 30, 2026.

Transparency log

Security for ua-banktools 0.4.0

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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for ua_banktools-0.4.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 30, 2026.

Transparency log

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