From 65ecca2507fb474398504d1c792eb08a04666a6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?dni=20=E2=9A=A1?= Date: Tue, 20 Aug 2024 11:52:39 +0200 Subject: [PATCH] feat: add rate endpoint per currency (#2641) this is already used and implemented by tpos, lnurlp and i probably need it for satspay aswell --- lnbits/core/views/api.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lnbits/core/views/api.py b/lnbits/core/views/api.py index 5202c926..8420247c 100644 --- a/lnbits/core/views/api.py +++ b/lnbits/core/views/api.py @@ -33,6 +33,7 @@ from lnbits.settings import settings from lnbits.utils.exchange_rates import ( allowed_currencies, fiat_amount_as_satoshis, + get_fiat_rate_satoshis, satoshis_amount_as_fiat, ) @@ -200,6 +201,12 @@ async def api_perform_lnurlauth( return "" +@api_router.get("/api/v1/rate/{currency}") +async def api_check_fiat_rate(currency: str) -> Dict[str, float]: + rate = await get_fiat_rate_satoshis(currency) + return {"rate": rate} + + @api_router.get("/api/v1/currencies") async def api_list_currencies_available() -> List[str]: return allowed_currencies()