Asynchronous Python API for Мой Газ.
Use pip to install the library:
pip install aiomygas
import asyncio
from pprint import pprint
import aiohttp
from aiomygas import SimpleMyGasAuth, MyGasApi
async def main(email: str, password: str) -> None:
"""Create the aiohttp session and run the example."""
async with aiohttp.ClientSession() as session:
auth = SimpleMyGasAuth(email, password, session)
api = MyGasApi(auth)
data = await api.async_get_accounts()
pprint(data)
if __name__ == "__main__":
_email = str(input("Email: "))
_password = str(input("Password: "))
asyncio.run(main(_email, _password))All exceptions inherit from MyGasApiError:
MyGasApiError— base class for all API errorsMyGasApiParseError— response parsing errorsMyGasAuthError— authentication errors
aiomygas does not specify any timeouts for any requests. You will need to specify them in your own code. We recommend asyncio.timeout:
import asyncio
async with asyncio.timeout(10):
data = await api.async_get_accounts()aiomygas-cli user@example.com password --accounts
aiomygas-cli user@example.com password --client
aiomygas-cli user@example.com password --charges
aiomygas-cli user@example.com password --payments
aiomygas-cli user@example.com password --info
python -m venv .venv
.venv/bin/pip install -r requirements_test.txt -e .
pytest tests/ -v