Monobank.ua API client
Project description
Python-monobankua
Python client library for Monobank API.
Installation
pip3 install monobankua
Requirements
- python >= 3.7
- 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_name, webhook_url, accounts = monobank.client_info()
print(client_name)
print(webhook_url)
for account in accounts:
print(f'{account.currency.name}: {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
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
File details
Details for the file monobankua-0.2.8.tar.gz
.
File metadata
- Download URL: monobankua-0.2.8.tar.gz
- Upload date:
- Size: 6.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.1.0 requests-toolbelt/0.9.1 tqdm/4.34.0 CPython/3.7.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 55a61987abd47342c9214c7b9838245bcd034462fedff647aa87ea2b9dafb3e6 |
|
MD5 | 6a1eb12ee106016beccdd6c90a44313a |
|
BLAKE2b-256 | 6ef8f712715906cd15307e29de4122a001eca014efb9026411af1024f0f5118b |
Provenance
File details
Details for the file monobankua-0.2.8-py3-none-any.whl
.
File metadata
- Download URL: monobankua-0.2.8-py3-none-any.whl
- Upload date:
- Size: 18.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.1.0 requests-toolbelt/0.9.1 tqdm/4.34.0 CPython/3.7.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 891348fa82ae44e2a8edd7bd695d9599b210f9e3b1bed09cd16a3f4929feae33 |
|
MD5 | bbf9d7e9110b28104e2487363d02064b |
|
BLAKE2b-256 | c260e3d1586b8611861daf821e6cbab7af37e762b0b0ab360219e68138c62ea2 |