Upgrade from Eikon -> Workspace. Learn about programming differences.

For a deeper look into our Eikon Data API, look into:

Overview |  Quickstart |  Documentation |  Downloads |  Tutorials |  Articles

question

Upvotes
Accepted
1 0 1 2

Backend Error 400 - python API - way to avoid?

Hi, I got always the same problem running a python script.

My RIC list is split into subsequences to allow the run.

microsoftteams-image.pngHow can I overcome this issue?

eikon-data-api#technology#productapierror-400
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

· Write an Answer
Upvote
Accepted
10.2k 18 6 9

@ilaria.leoni2 Thanks for your question and sorry to hear about your issue. So I cannot see the size of the field list (val_items) that you are using - but in general the guidance for per API call limits is given in this document. Generally you should try to code defensively in a try-except type structure where you can capture errors and try to re-present the failing API calls. Also consider the timing of the calls - around market opens is when loads on services are highest and can result in such errors.

instruments = ['CAD=','US2YT=RR','CA2YT=RR']
s = '2012-01-06'
e = '2023-03-01'
inv = 'daily'

data1 = pd.DataFrame()

for i in instruments:
    succeed = False
    while succeed == False:
        try:
            df1 = ek.get_timeseries(i,  # RICs
                fields=['CLOSE'],  # fields to be retrieved
                start_date=s,  # start time
                end_date=e,  # end time
                interval=inv)
            df1.rename(columns = {'CLOSE': i}, inplace = True)
            if len(data1):
                data1 = pd.concat([data1, df1], axis=1)
            else:
                data1 = df1
            succeed = True
        except:
            time.sleep(0.2)
        else:
            break
    else:
        var = "p"
data1

This is an example to show you how it might be implemented - you can swap the API call out with your one. I hope this can help.

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.