Python-monobankua
Python client library for Monobank API.
Installation
pip3 install monobankua
Requirements
- python >= 3.10
- requests >= 2.21
- ecdsa >= 0.13.2
Usage
Personal API
Full personal API description see at https://api.monobank.ua/docs/
- Create your token at https://api.monobank.ua/
- Use it to initialize client.
Code snippet
from datetime import datetime, timedelta
from monobankua import Monobank, MonobankError, MonobankRateLimitError, MonobankUnauthorizedError
try:
currencies_info = Monobank.currencies_info() # you don't need token to get an exchange rates
print(*currencies_info, sep='\n')
token = 'xxxxxxxxxxxxxxxxxxxxx'
monobank = Monobank(token)
client_info = monobank.client_info()
print(client_info)
print(client_info.webHookUrl)
for account in client_info.accounts:
print(f'{account.card}: {account}')
statements = monobank.statements(account.id, (datetime.now() - timedelta(days=6)).date())
print(*statements, sep='\n')
except MonobankRateLimitError:
print('Too many requests. Wait 1 minute, please')
except MonobankUnauthorizedError as e:
print(f'Some authorization problem: {e}')
except MonobankError as e:
print(e)
Corporate API
Corporate API has the same methods as personal API, but doesn't have rate limitation.
Corporate API is the only way for non-personal use of open Monobank API.
Full description see at https://api.monobank.ua/docs/corporate.html
- Generate private key. Sample shell command:
openssl ecparam -genkey -name secp256k1 -rand /dev/urandom -out priv.key
- Generate public key. Sample shell command:
openssl ec -in priv.key -pubout -out pub.key
-
Request API access. Send brief description of your service to api@monobank.ua with attached pub.key (be careful - not priv.key!).
-
Since Monobank approved your access, you should request user access.
-
Now, save request id to your DB or something else, and show the accept URL to user.
-
Check user acceptance & use all the same methods as for personal API.
Code snippet
from monobankua import MonobankCorporate
private_key = 'xxxxxxxxxxxxxxxxxxxxx' # from priv.key
request_id, accept_url = MonobankCorporate.access_request(private_key, statement=True, personal=True)
# you can set webhook URL to be notified about user acceptance:
# request_id, accept_url = MonobankCorporate.access_request(private_key, statement=True, personal=True, webhook_url='https://yourservice.com/hook/')
monobank_corporate = MonobankCorporate(private_key, request_id)
if monobank_corporate.access_check():
... # normal use the same way as for personal API
Metadata
Release files for monobankua 0.4.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| monobankua-0.4.5.tar.gz | 19.4 kB | Without provenance | Details for monobankua-0.4.5.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| monobankua-0.4.5-py3-none-any.whl | Python 3 | none | any | Details for monobankua-0.4.5-py3-none-any.whl |
Total release size: 38.9 kB
Release files / monobankua-0.4.5.tar.gz
| Download URL | monobankua-0.4.5.tar.gz |
|---|---|
| Size | 19.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
54a2773d435500493b45fcdf5064d981423a8beff6e92029dd0c1228650092a9
|
|
BLAKE2b-256 checksum How to use checksums |
305d7436e9ade52c3cb01624d2156f9e8927243650fb984bf3b0eaaab73d9074
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Release files / monobankua-0.4.5-py3-none-any.whl
| Download URL | monobankua-0.4.5-py3-none-any.whl |
|---|---|
| Size | 19.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f3115f3c3c722aadcbb833949cfea6b3995e8146a12d827978f3239e2d429fe2
|
|
BLAKE2b-256 checksum How to use checksums |
80dcc164e7d692a0e6060f504934974c1e95cc81d1f10374a91eaa49c167015e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Security for monobankua 0.4.5
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.