Skip to main content

This module is designed for quick interaction with the monobank API.

Project description

python-monobank-client

Documentation Status

This module provides quick integration of the Monobank API for developing applications based on synchronous and asynchronous frameworks.

Name

Python-Monobank-Client

Installation

This framework is published at the PyPI, install it with pip:

1.This package makes it possible to use module methods in synchronous frameworks:

pip install python-monobank-client[http]

2.This package makes it possible to use module methods in asynchronous frameworks:

pip install python-monobank-client[aio]

3.This package makes it possible to use ready-made views with a synchronous script based on the Django Rest framework:

pip install python-monobank-client[drf]

To get started, add the following packages to INSTALLED_APPS:

INSTALLED_APPS = [
    ...
    'rest_framework',
    'drf_mono',
]

Include drf_mono urls to your urls.py:

  urlpatterns = [
      ...
      path('mono/', include('drf_mono.urls', namespace='drf_mono')),
  ]

4.This package makes it possible to use ready-made routers with an asynchronous script based on the FastAPI framework:

pip install python-monobank-client[fastapi]

5.To install all packages at once:

pip install python-monobank-client[all]

Usage

  1. Request your token at https://api.monobank.ua/

  2. For a synchronous request use that token to initialize client:

    from sync_mono.manager import SyncMonoManager

    token = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"

    mng = SyncMonoManager(token)

  3. For an asynchronous request, use this token to initialize the client:

    from async_mono.manager import AsyncMonoManager

    token = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"

    mng = AsyncMonoManager(token)

Methods

Get currencies

>>> mng.get_currencies()
{
  "code": 200,
  "detail":
    [
      {
        "currencyCodeA": 840,
        "currencyCodeB": 980,
        "date": 1702591273,
        "rateBuy": 36.95,
        "rateSell": 37.4406
      },
      {
        "currencyCodeA": 978,
        "currencyCodeB": 980,
        "date": 1702623973,
        "rateBuy": 40.35,
        "rateSell": 41.1404
      },
      {
        "currencyCodeA": 978,
        "currencyCodeB": 840,
        "date": 1702623973,
        "rateBuy": 1.086,
        "rateSell": 1.1025
      },
      ...
    ]
}

Get currency

>>> mng.get_currency('USDUAH')
{
  "code": 200,
  "detail": {
    "USDUAH": {
      "Buy": 37.5,
      "Sale": 37.8702
    }
  }
}

Get client info

>>> mng.get_client_info()
{
  "code": 200,
  "detail":
    {
      "clientId": "xxxxxxxxxx",
      "name": "Last name First name",
      "webHookUrl": "",
      "permissions": "psfj",
      "accounts": [
        {
          "id": "xxxxxxxxxxxxxxxxxxx",
          "sendId": "xxxxxxxxxx",
          "currencyCode": 980,
          "cashbackType": "UAH",
          "balance": xxxxx,
          "creditLimit": 0,
          "maskedPan": [
            "xxxxxx******xxxx"
          ],
          "type": "black",
          "iban": "UAxxxxxxxxxxxxxxxxxxxxxxxxxxx"
        }
      ]
    }
}

Get balance

>>> mng.get_balance()
{
  "code": 200,
  "detail":
    {
      "balance": x.xx
    }
}

Get statement

>>> period = 31
>>> mng.get_statement(period)
{
  "code": 200,
  "detail":
    [
      {
        "id": "xxxxxxxxxxxxxxxxxx",
        "time": xxxxxxxxxx,
        "description": "xxxx xxxxx",
        "mcc": xxxx,
        "originalMcc": xxxx,
        "amount": -xxxxx,
        "operationAmount": -xxxxx,
        "currencyCode": xxx,
        "commissionRate": x,
        "cashbackAmount": xxx,
        "balance": xxxx,
        "hold": false,
        "receiptId": "xxxx-xxxx-xxxx-xxxx"
      },
      ...
    ]
}

Create a Webhook

>>> mng.create_webhook('https://myserver.com/hookpath')

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

python_monobank_client-0.1.0.tar.gz (15.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

python_monobank_client-0.1.0-py3-none-any.whl (18.3 kB view details)

Uploaded Python 3

File details

Details for the file python_monobank_client-0.1.0.tar.gz.

File metadata

  • Download URL: python_monobank_client-0.1.0.tar.gz
  • Upload date:
  • Size: 15.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for python_monobank_client-0.1.0.tar.gz
Algorithm Hash digest
SHA256 5526fbeaeacb8a1fe0a3db683fccaf30300b6e5a63682951f373140b00ddbd6e
MD5 b28b9fbd5032c4b4e38fc049f1c24daa
BLAKE2b-256 b47d39aacf669b3354b161d7ff0fa2803edaf24ba59f662dfa31cc5025194b74

See more details on using hashes here.

File details

Details for the file python_monobank_client-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for python_monobank_client-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5cfb47583297913f3ea68c61cd580ee2654e7c00d13761610cf3d07ebe08d689
MD5 85d90bfaeda20d403cbba02448cb418b
BLAKE2b-256 fd270301d2dfbc57b84b9dea50fd88540a16f053eb16968aa1007f404e13e474

See more details on using hashes here.

Supported by

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