Skip to content

Commit

Permalink
api: add fallback to coingecko for missing assets on dia (#1467)
Browse files Browse the repository at this point in the history
  • Loading branch information
ns212 authored Jul 19, 2023
1 parent 822e578 commit fa6782a
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions api/market_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,9 @@ def add_header(response):
def coingecko(args):
headers_dict = {
"content-type": "application/json",
"accept": "application/json",
"x-cg-pro-api-key": api_key,
"accept": "application/json"
}
url = "https://pro-api.coingecko.com/api/v3/simple/price"
url = "https://api.coingecko.com/api/v3/simple/price"
resp = requests.get(url, params=args, headers=headers_dict)
data = resp.json()
return data
Expand All @@ -64,7 +63,11 @@ def dia(asset):
}
}
except KeyError:
return { asset: None }
try:
return coingecko({"ids": [asset], "vs_currencies": ["usd"]})
except Exception as e:
print("Coingecko error", e)
return { asset: None }


@app.route("/marketdata/price", methods=["GET"])
Expand Down

1 comment on commit fa6782a

@vercel
Copy link

@vercel vercel bot commented on fa6782a Jul 19, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.