1
0
Fork 0
This repository has been archived on 2024-12-18. You can view files and clone it, but cannot push or open issues or pull requests.
mining-companion/companion/coingecko.py
Julien Riou 14aa8a6d59
Add "state" tests
Signed-off-by: Julien Riou <julien@riou.xyz>
2021-02-12 09:43:38 +01:00

14 lines
412 B
Python

import logging
import requests
logger = logging.getLogger(__name__)
def get_rate(ids, vs_currencies):
logger.debug(f'getting {ids} price in {vs_currencies} on coingecko')
url = f'https://api.coingecko.com/api/v3/simple/price?ids={ids}&vs_currencies={vs_currencies}'
r = requests.get(url)
r.raise_for_status()
logger.debug(r.json())
return r.json()[ids.lower()][vs_currencies.lower()]