Fio Banka API Client
Project description
Fio Banka API Client
Client for Fio Banka, a.s. API. Inspired by Honza Javorek's fiobank.
Description
This client is useful if you need to parse account info and transactions in 1 request (Fio banka imposes a limit of 1 request per 30 seconds) or if you want to fetch raw data (text or binary - e.g. PDF).
Currently, merchant transaction report and order upload are not implemented. Feel free to send a PR (I believe they should be reasonably easy to implement).
Fio Banka API documentation:
- Specification (Czech only)
- XSD Schema
Installation
pip install fio-banka
Usage
>>> from datetime import date
>>> import fio_banka
>>> account = fio_banka.Account("<API-token>")
>>> fmt = fio_banka.TransactionsFmt.JSON
>>> account.periods(date(2023, 1, 1), date(2023, 1, 2), fmt)
'{"accountStatement":{"info":{"accountId": ...(long output)... '
>>> try:
>>> account.last(fmt)
>>> except fio_banka.RequestError as exc:
>>> print(exc)
Exceeded time limit (1 request per 30s).
>>> import time
>>> time.sleep(fio_banka.REQUEST_TIMELIMIT)
>>> data = account.last(fmt)
>>> data
'{"accountStatement":{"info":{"accountId": ...(long output)... '
Data extraction (make sure data are downloaded as JSON):
>>> fio_banka.get_account_info(data)
AccountInfo(
account_id='2000000000',
bank_id='2010',
currency='CZK',
iban='CZ1000000000002000000000',
bic='FIOBCZPPXXX',
opening_balance=Decimal('1000.99'),
closing_balance=Decimal('2000.10'),
date_start=datetime.date(2023, 1, 1),
date_end=datetime.date(2023, 1, 3),
year_list=None,
id_list=None,
id_from=10000000000,
id_to=10000000002,
id_last_download=None
)
>>> list(fio_banka.get_transactions(data))[:2]
Transaction(
transaction_id='10000000000',
date=datetime.date(2023, 1, 1),
amount=Decimal('2000.0'),
currency='CZK',
account_id=None,
account_name='',
bank_id=None,
bank_name=None,
ks=None,
vs='1000',
ss=None,
user_identification='Nákup: example.com, dne 31.12.2022, částka 2000.00 CZK',
remittance_info='Nákup: example.com, dne 31.12.2022, částka 2000.00 CZK', # Zprava pro prijemce
type='Platba kartou',
executor='Novák, Jan',
specification=None,
comment='Nákup: example.com, dne 31.12.2022, částka 2000.00 CZK',
bic=None,
order_id=30000000000,
payer_reference=None
)
Transaction(
transaction_id="10000000001",
date=datetime.date(2023, 1, 2),
amount=Decimal("-1500.89"),
currency="CZK",
account_id="9876543210",
account_name="",
bank_id="0800",
bank_name="Česká spořitelna, a.s.",
ks="0558",
vs="0001",
ss="0002",
user_identification=None,
remittance_info=None, # Zprava pro prijemce
type="Okamžitá odchozí platba",
executor="Novák, Jan",
specification=None,
comment=None,
bic=None,
order_id=30000000001,
payer_reference=None,
)
Contributing
Build and activate development environment:
./build_venv
source venv/bin/activate
pre-commit install # https://pre-commit.com/
Run tests:
pytest
Use Conventional Commits.
License
This project is licensed under the terms of the MIT license.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for fio_banka-2.0.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fa881f758b51be9b8ad7c0da391905d8fb6b104da579557e1297712709d4c655 |
|
MD5 | 5d23585b71ecaa795211cbf4530e3340 |
|
BLAKE2b-256 | d94552dd5611fafe85fe141dfaf05e3364af2ad1e5b7b08dd30a3b84fa37d945 |