I was playing with the alphavantage API and was successfully able to receive the response for BTC to USD exchange rate.
{
'Realtime Currency Exchange Rate': {
'1. From_Currency Code': 'BTC',
'2. From_Currency Name': 'Bitcoin',
'3. To_Currency Code': 'USD',
'4. To_Currency Name': 'United States Dollar',
'5. Exchange Rate': '35172.07000000',
'6. Last Refreshed': '2022-01-22 16:39:01',
'7. Time Zone': 'UTC',
'8. Bid Price': '35172.06000000',
'9. Ask Price': '35172.07000000'
}
}
However, when I swap the currency, I mean convert USD to BTC, I get Invalid API call.
Below is what I'm trying to do
url = https://www.alphavantage.co/query?function=CURRENCY_EXCHANGE_RATE&from_currency=USD&to_currency=BTC&apikey=my_api_key`
r = requests.get(url)
{'Error Message': 'Invalid API call. Please retry or visit the documentation (https://www.alphavantage.co/documentation/) for CURRENCY_EXCHANGE_RATE.'}
I visited the document multiple times to confirm if I'm missing anything else but no luck. As per my understanding, the API call structure is exactly the same (including parameters) for either way of currency. So I'm really lost here and really don't have any idea what is wrong here. Any help would be appreciated.