-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
In batch api --> JSONDecodeError #53
Comments
Ok, I found the reason. Since I am using the free trial of the API, so they only allocate 5 requests per second for me. That's what caused the error. What you can do is to reduce your batch call to 5. I have tried to reduce the batch call to 20 or 10. But there are errors that occurred as well, though some of the batch calls may successfully requested. To fix this problem, you can either upgrade your plan or reduce your batch call to 5(if you are using IEX Apperate API). |
The request error can arise due to the requesting a large number of Batch API calls all at once
at end of
and you can change the call to 20 calls or less to see if it works. But make sure to remove it in the final code piece when making requests so that it will loop over every single stockEven after this, the main error occurs at data['symbol']
|
symbol_groups = list(chunks(stocks['Ticker'], 100))
symbol_strings = []
for i in range(0, len(symbol_groups)):
symbol_strings.append(','.join(symbol_groups[i]))
final_dataframe = pd.DataFrame(columns=my_col)
for symbol_string in symbol_strings:
batch_api_call_url = f'https://cloud.iexapis.com/stable/stock/market/batch/types=quote&symbols={symbol_string}&token={IEX_CLOUD_API_TOKEN}'
data = requests.get(batch_api_call_url).json()
for symbol in data:
if data[symbol]['quote']:
final_dataframe = final_dataframe.append(
pd.Series([symbol,
data[symbol]['quote']['latestPrice'],
data[symbol]['quote']['marketCap'],
'N/A'],
index=my_col),
ignore_index=True)
final_dataframe
The text was updated successfully, but these errors were encountered: