Metadata-Version: 2.2
Name: python-monobank-client
Version: 0.1.0
Summary: This module is designed for quick interaction with the monobank API.
Home-page: https://gitlab.onix.ua/onix-systems/python-internal-mono
Author: Viacheslav Lisovoi
Author-email: viacheslav.lisovoi@onix-systems.com
Keywords: files speedfiles
Classifier: Programming Language :: Python :: 3.11
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Requires-Python: >=3.6
Description-Content-Type: text/markdown
License-File: LICENSE.md
Requires-Dist: python-dotenv==1.0.0
Provides-Extra: http
Requires-Dist: requests>=2.25.1; extra == "http"
Provides-Extra: aio
Requires-Dist: aiohttp==3.9.1; extra == "aio"
Provides-Extra: drf
Requires-Dist: Django<5,>=4; extra == "drf"
Requires-Dist: djangorestframework; extra == "drf"
Requires-Dist: requests>=2.25.1; extra == "drf"
Provides-Extra: fastapi
Requires-Dist: fastapi[all]; extra == "fastapi"
Requires-Dist: sqlalchemy; extra == "fastapi"
Requires-Dist: psycopg2; extra == "fastapi"
Requires-Dist: asyncpg; extra == "fastapi"
Provides-Extra: all
Requires-Dist: Django<5,>=4; extra == "all"
Requires-Dist: djangorestframework; extra == "all"
Requires-Dist: requests>=2.25.1; extra == "all"
Requires-Dist: fastapi[all]; extra == "all"
Requires-Dist: aiohttp==3.9.1; extra == "all"
Requires-Dist: sqlalchemy; extra == "all"
Requires-Dist: psycopg2; extra == "all"
Requires-Dist: asyncpg; extra == "all"
Requires-Dist: alembic; extra == "all"
Dynamic: author
Dynamic: author-email
Dynamic: classifier
Dynamic: description
Dynamic: description-content-type
Dynamic: home-page
Dynamic: keywords
Dynamic: provides-extra
Dynamic: requires-dist
Dynamic: requires-python
Dynamic: summary

# python-monobank-client
[![Documentation Status](https://readthedocs.org/projects/python-monobank-client/badge/?version=latest)](https://python-monobank-client.readthedocs.io/en/latest/?badge=latest)

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
```python
>>> 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
```python
>>> mng.get_currency('USDUAH')
{
  "code": 200,
  "detail": {
    "USDUAH": {
      "Buy": 37.5,
      "Sale": 37.8702
    }
  }
}
```

Get client info
```python
>>> 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
```python
>>> mng.get_balance()
{
  "code": 200,
  "detail":
    {
      "balance": x.xx
    }
}
```

Get statement
```python
>>> 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
```python
>>> mng.create_webhook('https://myserver.com/hookpath')
```
