I have code in python that periodically fetches data for a particular ticker.
import pandas as pd
import time
def intraday(ticker, interval, key):
"""
Returns interday data
"""
url = f'https://www.alphavantage.co/query?function=TIME_SERIES_INTRADAY&symbol={ticker}&interval={interval}&apikey={key}&datatype=csv'
df = pd.read_csv(url)
df = df.reset_index()
while True:
print(intraday('AAPL', '1min', key)
time.sleep(60)
The problem that I face, is that this code works well most of the time. However, occasionally, it throws an error, saying "Invalid API call".
This doesn't happen all the time. Maybe once is 3-4 calls. Sometimes at in the first call.
I'm in no way modifying anything else as well
What's going on?