From 0aa19ca6bf4453b4edeb9bcc6a50d063e615f1ad Mon Sep 17 00:00:00 2001 From: jwinterm Date: Tue, 26 May 2026 15:04:46 -0400 Subject: [PATCH] feat(public): add GET /api/core/public/rate?currency=usd MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Exposes the WOW→fiat spot rate the invoice path already uses internally (Nonlogs WOW-BTC × Kraken BTC-USD, 60s cache). No auth. Allows downstream services (Medusa storefront) to display a live USD reference price for WOW-denominated products without hard-coding a third-party rate provider on the storefront side. --- api/app/routes.py | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/api/app/routes.py b/api/app/routes.py index 574beb5..b6cf79f 100644 --- a/api/app/routes.py +++ b/api/app/routes.py @@ -627,6 +627,39 @@ def get_public_system_status(db: Session = Depends(get_db)): return _load_public_system_status(db) +@router.get("/api/core/public/rate") +def get_public_rate(currency: str = "usd"): + """ + Public WOW→fiat spot rate. Returns the same QuoteResult that the + invoice-creation paths use internally (60s in-process cache, sourced + from Nonlogs WOW-BTC × Kraken BTC-USD). + + No auth — this is the same data the marketing storefront would + otherwise have to scrape from Nonlogs directly. Exposing it lets + downstream consumers (Medusa) get an authoritative-on-our-side + rate without hard-coding a third-party API. + """ + try: + quote = get_wow_rate(currency) + except ValueError as exc: + raise HTTPException( + status_code=status.HTTP_400_BAD_REQUEST, + detail=str(exc), + ) from exc + except (RequestException, RuntimeError) as exc: + raise HTTPException( + status_code=status.HTTP_503_SERVICE_UNAVAILABLE, + detail=f"Rate temporarily unavailable: {exc}", + ) from exc + return { + "rate": str(quote.rate), + "currency": quote.currency, + "source": quote.source, + "quoted_at": quote.quoted_at.isoformat(), + "base": "WOW", + } + + @router.post("/api/core/webhooks", response_model=WebhookResponse) def register_webhook( payload: WebhookCreate,