2025-01-09 00:04:31 +03:00
|
|
|
import yaml
|
|
|
|
import aiohttp
|
|
|
|
|
|
|
|
from http import HTTPStatus
|
|
|
|
|
|
|
|
config = yaml.safe_load(open('config.yaml'))
|
|
|
|
|
|
|
|
async def create_chart(from_currency: str, conv_currency: str) -> (dict, None):
|
|
|
|
async with aiohttp.ClientSession(timeout=aiohttp.ClientTimeout(total=3)) as session:
|
2025-01-09 13:26:57 +03:00
|
|
|
async with session.get(f'{config["kekkai_instance"]}/api/getChart/month/', params={
|
2025-01-09 00:04:31 +03:00
|
|
|
'from_currency': from_currency,
|
|
|
|
'conv_currency': conv_currency
|
|
|
|
}) as res:
|
|
|
|
if not HTTPStatus(res.status).is_success:
|
|
|
|
return None
|
|
|
|
|
|
|
|
data = await res.json()
|
|
|
|
|
|
|
|
return data.get('message', None)
|