From a0d98b197f70e53c0d0043d2db1919b64131f631 Mon Sep 17 00:00:00 2001 From: Ryana May Que Date: Fri, 6 Sep 2024 11:31:31 +0800 Subject: [PATCH] add: quote route --- app/api/v1/routes/stock.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/app/api/v1/routes/stock.py b/app/api/v1/routes/stock.py index 4f6a300..8729c24 100644 --- a/app/api/v1/routes/stock.py +++ b/app/api/v1/routes/stock.py @@ -19,4 +19,17 @@ async def lookup(query: str, exchange: str | None = None): params["exchange"] = exchange response = requests.get("https://finnhub.io/api/v1/search", params=params) - return response.json() \ No newline at end of file + return response.json() + +@router.get("/quote") +async def quote(symbol: str): + """ + API to get a stock quote. + """ + params = { + "token": settings.FINNHUB_API_KEY, + "symbol": symbol + } + + response = requests.get("https://finnhub.io/api/v1/quote", params=params) + return response.json()