Skip to main content

Monobank.ua API client

Project description

Python-monobankua

PyPI Build Status License: GPL v3

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/

  1. Create your token at https://api.monobank.ua/
  2. 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.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

  1. Generate private key. Sample shell command:
openssl ecparam -genkey -name secp256k1 -rand /dev/urandom -out priv.key
  1. Generate public key. Sample shell command:
openssl ec -in priv.key -pubout -out pub.key
  1. Request API access. Send brief description of your service to api@monobank.ua with attached pub.key (be careful - not priv.key!).

  2. Since Monobank approved your access, you should request user access.

  3. Now, save request id to your DB or something else, and show the accept URL to user.

  4. 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

monobankua-0.4.1.tar.gz (6.3 kB view details)

Uploaded Source

Built Distribution

monobankua-0.4.1-py3-none-any.whl (19.0 kB view details)

Uploaded Python 3

File details

Details for the file monobankua-0.4.1.tar.gz.

File metadata

  • Download URL: monobankua-0.4.1.tar.gz
  • Upload date:
  • Size: 6.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/51.1.2 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.7.1

File hashes

Hashes for monobankua-0.4.1.tar.gz
Algorithm Hash digest
SHA256 2c7310df9f776854a5e9f97e4517d53f08f0675e391d4e85dc206c8406d5ab9c
MD5 b3ac9fe766d7b662e7fd16bb02ae4673
BLAKE2b-256 312c024be5aa8cbbedd858b05897d3172d7cf696075123c760ecf673ac83fb5a

See more details on using hashes here.

Provenance

File details

Details for the file monobankua-0.4.1-py3-none-any.whl.

File metadata

  • Download URL: monobankua-0.4.1-py3-none-any.whl
  • Upload date:
  • Size: 19.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/51.1.2 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.7.1

File hashes

Hashes for monobankua-0.4.1-py3-none-any.whl
Algorithm Hash digest
SHA256 6cff8ae9184bfdefa428fe8effff756c65e96724824a11b3bade42cd0f16c251
MD5 893b4aed3dca9ecd376acb4d6227bb0e
BLAKE2b-256 32900813f40fee99aa6aa72c58265e906664dec573050429da9f8e70bf7f0486

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page