# YCLIENTS API async client
[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/yclients-aio-client.svg)](https://pypi.org/project/yclients-aio-client/)
[![PyPi Package](https://img.shields.io/pypi/v/yclients-aio-client.svg)](https://pypi.org/project/yclients-aio-client/)
[![Codecov](https://codecov.io/gh/akimrx/yclients-aio-client/branch/master/graph/badge.svg)](https://app.codecov.io/gh/akimrx/yclients-aio-client)
[![Codacy Badge](https://app.codacy.com/project/badge/Grade/0fcaff61147141e496f9843a13295242)](https://app.codacy.com/gh/akimrx/yclients-aio-client/dashboard?utm_source=gh&utm_medium=referral&utm_content=&utm_campaign=Badge_grade)
[![Tests](https://github.com/akimrx/yclients-aio-client/workflows/Tests/badge.svg)](https://github.com/akimrx/yclients-aio-client)
[![Build](https://github.com/akimrx/yclients-aio-client/workflows/Publish/badge.svg)](https://github.com/akimrx/yclients-aio-client)
**Important. This library is not official!**
Asynchronous client for interacting with the [YCLIENTS API](https://developer.yclients.com).
To work with the YCLIENTS API, you will need a partner token (Bearer), which can be obtained by [following the link](https://yclients.com/appstore/developers/registration).
## Installing
> Python version required: >= 3.10.*
* Installing with [pip](https://pypi.org/project/yclients-aio-client/):
```bash
pip3 install yclients-aio-client
```
* Also, you can install from source with:
```bash
git clone https://github.com/akimrx/yclients-aio-client --recursive
cd yclients-aio-client
make install
```
or
```bash
git clone https://github.com/akimrx/yclients-aio-client --recursive
cd yclients-aio-client
python3 setup.py install
```
## Getting started
### Backoff strategy
Each HTTP request, in case of failure, will be repeated a limited number of times, using an exponential backoff strategy with jitter.
The number of attempts, the delay time between them and the jitter range can be changed using environment variables.
* `YCLIENTS_BACKOFF_MAX_TRIES` — Maximum number of total call attempts if the HTTP request failed
* `YCLIENTS_BACKOFF_JITTER` — Enables jitter if True is passed
* `YCLIENTS_BACKOFF_BASE_DELAY` – Basic delay between attempts (dynamic when jitter is on)
* `YCLIENTS_BACKOFF_EXPO_FACTOR` – Multiplier for exponential backoff
You can use an additional backoff for your methods through the decorator `yclients_aio_client.utils.decorators.backoff`, however, it is not necessary to decore already decorated default cases:
* Internal Server Errors, i.e. 5xx HTTP-codes
* Network Errors, i.e. DNS, connect and socket fails
### Sync usage
If your code is synchronous and you don't want to use async for some reason, you can wrap the func calls with `asyncio.run`.
```python
import asyncio
from typing import Coroutine, Any
from yclients_aio_client import AsyncYclientsClient
partner_token = "xxxxxxxxxxxxxxxxxxxx"
yclients = AsyncYclientsClient(partner_token=partner_token, raise_client_errors=True)
def _(coroutine: Coroutine) -> Any:
"""Wrapper for run async fucntion synchronous."""
return asyncio.run(coroutine)
def authenticate_user(user: str, password: str) -> str:
"""Get user token by user:password pair."""
result = _(yclients.auth.get_user_token(user, password))
return result.data.user_token
```
[See full example](/examples/sync_wrapper.py)
### Logging
This library uses the `logging` module.
Example of usage:
```python
import logging
logging.basicConfig(
level=logging.INFO,
format='[%(levelname)s] %(message)s'
)
logger = logging.getLogger(__name__)
```
Change library log level:
```python
import logging
logging.getLogger("yclients_aio_client").setLevel(logging.ERROR)
```
Raw data
{
"_id": null,
"home_page": "https://github.com/akimrx/yclients-aio-client",
"name": "yclients-aio-client",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.10",
"maintainer_email": "",
"keywords": "yclients,async",
"author": "akimrx",
"author_email": "akimstrong@yandex.ru",
"download_url": "https://files.pythonhosted.org/packages/5d/3c/73c7754262d6faf5d8e8de1b75bb8f523a019086d2a11e288dfdca1a4226/yclients-aio-client-0.0.1.tar.gz",
"platform": "osx",
"description": "# YCLIENTS API async client\n\n[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/yclients-aio-client.svg)](https://pypi.org/project/yclients-aio-client/)\n[![PyPi Package](https://img.shields.io/pypi/v/yclients-aio-client.svg)](https://pypi.org/project/yclients-aio-client/)\n[![Codecov](https://codecov.io/gh/akimrx/yclients-aio-client/branch/master/graph/badge.svg)](https://app.codecov.io/gh/akimrx/yclients-aio-client)\n[![Codacy Badge](https://app.codacy.com/project/badge/Grade/0fcaff61147141e496f9843a13295242)](https://app.codacy.com/gh/akimrx/yclients-aio-client/dashboard?utm_source=gh&utm_medium=referral&utm_content=&utm_campaign=Badge_grade)\n[![Tests](https://github.com/akimrx/yclients-aio-client/workflows/Tests/badge.svg)](https://github.com/akimrx/yclients-aio-client)\n[![Build](https://github.com/akimrx/yclients-aio-client/workflows/Publish/badge.svg)](https://github.com/akimrx/yclients-aio-client)\n\n**Important. This library is not official!**\n\nAsynchronous client for interacting with the [YCLIENTS API](https://developer.yclients.com). \nTo work with the YCLIENTS API, you will need a partner token (Bearer), which can be obtained by [following the link](https://yclients.com/appstore/developers/registration).\n\n## Installing\n\n> Python version required: >= 3.10.*\n\n* Installing with [pip](https://pypi.org/project/yclients-aio-client/):\n```bash\npip3 install yclients-aio-client\n```\n \n* Also, you can install from source with:\n\n```bash\ngit clone https://github.com/akimrx/yclients-aio-client --recursive\ncd yclients-aio-client\nmake install\n```\n \nor\n \n```bash\ngit clone https://github.com/akimrx/yclients-aio-client --recursive\ncd yclients-aio-client\npython3 setup.py install\n```\n\n## Getting started\n\n\n### Backoff strategy\n\nEach HTTP request, in case of failure, will be repeated a limited number of times, using an exponential backoff strategy with jitter. \nThe number of attempts, the delay time between them and the jitter range can be changed using environment variables.\n\n* `YCLIENTS_BACKOFF_MAX_TRIES` \u2014 Maximum number of total call attempts if the HTTP request failed\n* `YCLIENTS_BACKOFF_JITTER` \u2014 Enables jitter if True is passed\n* `YCLIENTS_BACKOFF_BASE_DELAY` \u2013 Basic delay between attempts (dynamic when jitter is on)\n* `YCLIENTS_BACKOFF_EXPO_FACTOR` \u2013 Multiplier for exponential backoff\n\nYou can use an additional backoff for your methods through the decorator `yclients_aio_client.utils.decorators.backoff`, however, it is not necessary to decore already decorated default cases:\n* Internal Server Errors, i.e. 5xx HTTP-codes\n* Network Errors, i.e. DNS, connect and socket fails\n\n### Sync usage\nIf your code is synchronous and you don't want to use async for some reason, you can wrap the func calls with `asyncio.run`. \n\n```python\nimport asyncio\nfrom typing import Coroutine, Any\nfrom yclients_aio_client import AsyncYclientsClient\n\npartner_token = \"xxxxxxxxxxxxxxxxxxxx\"\nyclients = AsyncYclientsClient(partner_token=partner_token, raise_client_errors=True)\n\n\ndef _(coroutine: Coroutine) -> Any:\n \"\"\"Wrapper for run async fucntion synchronous.\"\"\"\n return asyncio.run(coroutine)\n\n\ndef authenticate_user(user: str, password: str) -> str:\n \"\"\"Get user token by user:password pair.\"\"\"\n result = _(yclients.auth.get_user_token(user, password))\n return result.data.user_token\n```\n\n[See full example](/examples/sync_wrapper.py)\n\n\n### Logging\n\nThis library uses the `logging` module.\n\nExample of usage:\n\n```python\nimport logging\n\nlogging.basicConfig(\n level=logging.INFO,\n format='[%(levelname)s] %(message)s'\n)\nlogger = logging.getLogger(__name__)\n```\n\nChange library log level:\n```python\nimport logging\n\nlogging.getLogger(\"yclients_aio_client\").setLevel(logging.ERROR)\n```\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Async client for YCLIENTS API",
"version": "0.0.1",
"project_urls": {
"Homepage": "https://github.com/akimrx/yclients-aio-client"
},
"split_keywords": [
"yclients",
"async"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "122812a0a8ac68c9fb9eb4a872e910108fa44a5a6ad10371d6d2f1ad713d0819",
"md5": "61ed26446ba8a511ff946da3cb08a67e",
"sha256": "528e3caf415e29195de2ed5e6ce118e39e15d3cb1bbfc44957c8e09e14a9ddca"
},
"downloads": -1,
"filename": "yclients_aio_client-0.0.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "61ed26446ba8a511ff946da3cb08a67e",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.10",
"size": 6952,
"upload_time": "2023-10-10T07:48:41",
"upload_time_iso_8601": "2023-10-10T07:48:41.885234Z",
"url": "https://files.pythonhosted.org/packages/12/28/12a0a8ac68c9fb9eb4a872e910108fa44a5a6ad10371d6d2f1ad713d0819/yclients_aio_client-0.0.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "5d3c73c7754262d6faf5d8e8de1b75bb8f523a019086d2a11e288dfdca1a4226",
"md5": "1e128dde4ef94355b59f2bd69a703dcd",
"sha256": "fa030a69af53195c2f770791f792d730f5b0b2e1752e0d1baf1452e3af85a352"
},
"downloads": -1,
"filename": "yclients-aio-client-0.0.1.tar.gz",
"has_sig": false,
"md5_digest": "1e128dde4ef94355b59f2bd69a703dcd",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.10",
"size": 5933,
"upload_time": "2023-10-10T07:48:43",
"upload_time_iso_8601": "2023-10-10T07:48:43.316191Z",
"url": "https://files.pythonhosted.org/packages/5d/3c/73c7754262d6faf5d8e8de1b75bb8f523a019086d2a11e288dfdca1a4226/yclients-aio-client-0.0.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-10-10 07:48:43",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "akimrx",
"github_project": "yclients-aio-client",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"requirements": [],
"lcname": "yclients-aio-client"
}