Shirino/functions/create_chart.py
Redume 65236eeec8
Some checks failed
Create and publish a Docker image / build-and-push-image (push) Has been cancelled
chore: Changed the key to get the schedule
2025-04-21 21:12:00 +03:00

20 lines
689 B
Python

from http import HTTPStatus
import yaml
import aiohttp
config = yaml.safe_load(open('../config.yaml', 'r', encoding='utf-8'))
async def create_chart(from_currency: str, conv_currency: str) -> (dict, None):
async with aiohttp.ClientSession(timeout=aiohttp.ClientTimeout(total=3)) as session:
async with session.get(
f'{config["kekkai_instance"]}/api/getChart/month/', params={
'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('detail', None)