-4

So I've recently been trying to build a bitcoin price tracker into my discord bot using the yfinance API, but it doesn't show me the price whenever I run the command, does anyone know how? For context, this is the result I always get:

Open  ...       Volume
Date                      ...
2022-01-08  36663.851562  ...  71013384192

[1 rows x 6 columns]

And here's the code

@bot.command(name='BTCstalker', help='Posts updates on BTC.')
async def cyrdat(ctx):
    cryptoData = yf.download(tickers="BTC-EUR", period='1d', interval='1d')
    content = (cryptoData)
    await ctx.send(content)
Bart Kiers
  • 166,582
  • 36
  • 299
  • 288
  • This might be a solution for you https://stackoverflow.com/questions/61104362/how-to-get-actual-stock-prices-with-yfinance – Josh Ackland Jan 08 '22 at 13:47

1 Answers1

0

Get the price in USD

import requests
response = requests.get('https://api.coindesk.com/v1/bpi/currentprice.json')
data = response.json()
price = data["bpi"]["USD"]["rate"]

Short

import requests
data = requests.get('https://api.coindesk.com/v1/bpi/currentprice.json').json()["bpi"]["USD"]["rate"]