Skip to content

Commit

Permalink
Added latest coins and golds prices api too (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
daniyalmaroufi authored Apr 6, 2024
1 parent 8c8df50 commit 185d610
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
8 changes: 6 additions & 2 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,12 @@ async def read_archive(date: str = (datetime.date.today() - datetime.timedelta(d
@cache(expire=60 * 30)
async def read_latest():
token = get_token_from_main_page()
currencies, _, _ = get_prices_from_api(token)
return {c.code.lower(): {"sell": c.sell, "buy": c.buy} for c in currencies}
currencies, coins, golds = get_prices_from_api(token)
currencies_data = {c.code.lower(): {"sell": c.sell, "buy": c.buy} for c in currencies}
coins_data = {c.code.lower(): {"sell": c.sell, "buy": c.buy} for c in coins}
golds_data = {c.code.lower(): {"sell": c.price, "buy": c.price} for c in golds}

return {**currencies_data, **coins_data, **golds_data}


@app.get("/archive/range")
Expand Down
6 changes: 3 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ certifi==2023.5.7
charset-normalizer==2.0.12
click==8.1.3
exceptiongroup==1.1.1
fastapi==0.78.0
fastapi==0.110.1
fastapi-cache2==0.1.8
h11==0.14.0
httpcore==0.16.3
Expand All @@ -26,7 +26,7 @@ rich==13.4.0
six==1.16.0
sniffio==1.3.0
soupsieve==2.4.1
starlette==0.27.0
typing_extensions==4.6.2
starlette==0.37.2
typing_extensions==4.10.0
urllib3==1.26.16
uvicorn==0.17.6

0 comments on commit 185d610

Please sign in to comment.