YCLIENTS API async client
Important. This library is not official!
Asynchronous client for interacting with the YCLIENTS API.
To work with the YCLIENTS API, you will need a partner token (Bearer), which can be obtained by following the link.
Installing
Python version required: >= 3.10.*
- Installing with pip:
pip3 install yclients-aio-client
- Also, you can install from source with:
git clone https://github.com/akimrx/yclients-aio-client --recursive
cd yclients-aio-client
make install
or
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 failedYCLIENTS_BACKOFF_JITTER— Enables jitter if True is passedYCLIENTS_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.
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
Logging
This library uses the logging module.
Example of usage:
import logging
logging.basicConfig(
level=logging.INFO,
format='[%(levelname)s] %(message)s'
)
logger = logging.getLogger(__name__)
Change library log level:
import logging
logging.getLogger("yclients_aio_client").setLevel(logging.ERROR)
Metadata
Release files for yclients-aio-client 0.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| yclients-aio-client-0.0.1.tar.gz | 5.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| yclients_aio_client-0.0.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 12.9 kB
Release files / yclients-aio-client-0.0.1.tar.gz
| Download URL | yclients-aio-client-0.0.1.tar.gz |
|---|---|
| Size | 5.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
fa030a69af53195c2f770791f792d730f5b0b2e1752e0d1baf1452e3af85a352
|
|
BLAKE2b-256 checksum How to use checksums |
5d3c73c7754262d6faf5d8e8de1b75bb8f523a019086d2a11e288dfdca1a4226
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.9.18
|
Release files / yclients_aio_client-0.0.1-py3-none-any.whl
| Download URL | yclients_aio_client-0.0.1-py3-none-any.whl |
|---|---|
| Size | 7.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
528e3caf415e29195de2ed5e6ce118e39e15d3cb1bbfc44957c8e09e14a9ddca
|
|
BLAKE2b-256 checksum How to use checksums |
122812a0a8ac68c9fb9eb4a872e910108fa44a5a6ad10371d6d2f1ad713d0819
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.9.18
|