Skip to content

Commit

Permalink
api: select price source via query param and ticker renaming (#1307)
Browse files Browse the repository at this point in the history
  • Loading branch information
ns212 authored Jun 19, 2023
1 parent 4a19226 commit 4e1c721
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions api/market_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@

api_key = os.environ.get("CG_API_KEY")

tickers = {
"tether usd": "tether",
}

@app.after_request
def add_header(response):
Expand Down Expand Up @@ -47,8 +50,11 @@ def dia(asset):
resp = requests.get(url, headers=headers_dict)
data = resp.json()

# optionally rename the ticker
ticker = tickers.get(data["Name"], data["Name"]).lower()

return {
data["Name"].lower(): {
ticker: {
"usd": data["Price"],
}
}
Expand All @@ -58,7 +64,7 @@ def dia(asset):
def get_price():
args = request.args

price_source = request.headers.get('x-price-source')
price_source = args.get('price-source')

data = {}

Expand Down

2 comments on commit 4e1c721

@vercel
Copy link

@vercel vercel bot commented on 4e1c721 Jun 19, 2023

Choose a reason for hiding this comment

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

@vercel
Copy link

@vercel vercel bot commented on 4e1c721 Jun 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.