Discover Refinitiv
MyRefinitiv Refinitiv Perspectives Careers
Created with Sketch.
All APIs Questions & Answers  Register |  Login
Ask a question
  • Questions
  • Tags
  • Badges
  • Unanswered
Search:
  • Home /
  • Eikon Data APIs /
avatar image
Question by dshi · May 23, 2018 at 02:08 PM · pythonpython api eikon400 bad request

HTTP Error: Backend error. 400 Bad Request

Hi, I'm trying to pull some data with the following:

screener_tsvx = "SCREEN(U(IN(Equity(active,public,primary))/*UNV:Public*/), IN(TR.ExchangeMarketIdCode,""TSXV"",""XTNX"",""XTSE"",""XTSX""), TR.AvgDailyValTraded20D>=GMEDIAN(ZAV(TR.AvgDailyValTraded20D),universe=""univ""), CURN=CAD)" 
ek.get_data([screener_tsvx],["TR.CommonName"])
# ek.get_data([screener_tsx],["TR.CommonName;TR.InstrumentType;TR.CompanyMarketCap"])

It works in excel, but in my jupyter notebook I get the following HTTPError:

---------------------------------------------------------------------------
HTTPError                                 Traceback (most recent call last)
<ipython-input-100-fa4ae8947122> in <module>()
      1 screener_tsvx = "SCREEN(U(IN(Equity(active,public,primary))/*UNV:Public*/), IN(TR.ExchangeMarketIdCode,""TSXV"",""XTNX"",""XTSE"",""XTSX""), TR.AvgDailyValTraded20D>=GMEDIAN(ZAV(TR.AvgDailyValTraded20D),universe=""univ""), CURN=CAD)"
----> 2 ek.get_data([screener_tsvx],["TR.CommonName"])
      3 # ek.get_data([screener_tsx],["TR.CommonName;TR.InstrumentType;TR.CompanyMarketCap"])

~\Anaconda3\lib\site-packages\eikon\data_grid.py in get_data(instruments, fields, parameters, field_name, raw_output, debug)
    149     payload = {'instruments': instruments,'fields': fields_for_request}
    150     if parameters: payload.update({'parameters': parameters})
--> 151     result = eikon.json_requests.send_json_request(DataGrid_UDF_endpoint, payload, debug=debug)
    152 
    153     if raw_output:

~\Anaconda3\lib\site-packages\eikon\json_requests.py in send_json_request(entity, payload, ID, debug)
     85             if response.status_code == 200:
     86                 result = response.json()
---> 87                 check_server_error(result)
     88                 return result
     89             if response.status_code == 401:

~\Anaconda3\lib\site-packages\eikon\json_requests.py in check_server_error(server_response)
    133         else:
    134             status_code = server_response['ErrorCode']
--> 135         raise requests.HTTPError(error_message, response=server_response)
    136 
    137     # check DataGrid error

HTTPError: Backend error. 400 Bad Request

I've seen some suggestions of queries timing out, but I'm not sure if this is the case. I've also been unable to find a detailed documentation on how the `instruments` field for the get_data function can be specified. I've been trying to use the Screener function as a work around, and now I've run into the HTTP Backend error. Not entirely sure what my options are now. Any suggestions, advice would be nice.

Thank you!

People who like this

0 Show 0
Comment
10 |1500 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

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

2 Replies

  • Sort: 
avatar image
REFINITIV
Best Answer
Answer by Alex Putkov. · May 23, 2018 at 04:55 PM

The use of equity screener through Eikon Data APIs is not supported yet. One reason for this is that currently any get_data request is automatically timed out from the server side if the server cannot return the data requested in 15 seconds. Rendering the data through screener can take much longer than 15 seconds to complete, in which case you get back "HTTPError: Backend error. 400 Bad Request". Work is being done to address this issue. Until this work is complete the screener through Eikon Data APIs can only be used for basic expressions that the server can render in less than 15 seconds.

Could you elaborate on what you expect from "detailed documentation on how the instruments field for the get_data function can be specified"? It seems you've already checked the "Eikon Data APIs for Python - Reference Guide" available from the Documentation tab on Eikon Data APIs page on this portal, which provides definition of all the methods and their signatures available in Eikon Data APIs for Python. Per this document the "instruments" argument is a string representing an identifier for a single instrument or a list of strings where each string represents an instrument identifier. For instrument identifier you can use a variety of symbol types including RIC, ISIN, CUSIP, SEDOL, Wertpapierkennnummer, PermID etc. If you have a list of instrument identifiers for which you need market or fundamental & reference data, you can use this list directly to retrieve the data using get_data method, e.g.

ek.get_data(['TRI.N','AAPL.O'],['TR.Revenue'])
The screener is useful when you need to identify stocks that satisfy your criteria.
Comment
zoya.farberov
dshi

People who like this

2 Show 12 · Share
10 |1500 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

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

avatar image
dshi · May 24, 2018 at 11:20 AM 0
Share

I guess I'm asking if there's a list that provides all possible types of values that the get_data `instruments` field can take. For example, I can provide `['TRI.N', 'AAPL.O']` which is a list of symbols. I could also use `'#0.SPX'`, as well as `"SCREEN()"` or `"PORTFOLIO()"`. I was wondering what other options there are and whether or not there is a documented list of allowed methods available.

Thank you!

avatar image
REFINITIV
Alex Putkov. ♦♦ dshi · May 24, 2018 at 11:57 AM 1
Share

I see. Well, you pretty much listed all of them. The only one you missed is "LISTS()", which is similar to "PORTFOLIO()". When instruments argument is a single string, it can take the same string values you can provide to the first argument of =TR function in Excel, notwithstanding the known issue with the server timeout that I described earlier.

avatar image
REFINITIV
Alex Putkov. ♦♦ dshi · May 24, 2018 at 11:57 AM 1
Share

The values the Universe argument of =TR function can take are documented in the Help, which you can access from the Thomson Reuters tab in Eikon Excel ribbon. But even this documentation is not necessarily all exhaustive. E.g. it doesn't specifically mention using chain RICs such as "0#.SPX" as universe, and we may be adding other types of universes in the future.

avatar image
dshi Alex Putkov. ♦♦ · May 24, 2018 at 02:53 PM 0
Share

Ok, Thank you!

avatar image
D · Dec 18, 2019 at 12:24 AM 0
Share

Hi,

Any updates getting equity screener support in the API? I'm still getting the same timeout error.

avatar image
REFINITIV
Alex Putkov. ♦♦ D · Dec 18, 2019 at 10:22 PM 1
Share

Make sure you use the latest version of Eikon Data APIs library for Python. Version 1.0.1 of the library released in May 2019 introduced a fix that greatly reduced the occurrence of "EikonError: Error code 400 | Backend error. 400 Bad Request" due to timeouts from the backend. Currently the most recent production version of Eikon Data APIs library for Python on PYPI is v1.0.2.

avatar image
D Alex Putkov. ♦♦ · Dec 18, 2019 at 11:49 PM 0
Share

Yeah I'm definitely on 1.0.2. Guess I'll find another way. Thanks

avatar image
Answer by lovelmark · Feb 26, 2020 at 04:50 AM

The 400 Bad Request error is an HTTP status code indicates that the request you sent to the webserver was malformed , in other words, the data stream sent by the client to the server didn't follow the rules. It means that the request itself has somehow incorrect or corrupted and the server couldn't understand it. There are a number of different causes for a 400: Bad Request Error . It might be a malformed request syntax, invalid request message framing, or deceptive request routing . In most cases, the problem is on the website itself, and there's not much you can do about that.

Comment

People who like this

0 Show 0 · Share
10 |1500 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

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

Watch this question

Add to watch list
Add to your watch list to receive emailed updates for this question. Too many emails? Change your settings >
11 People are following this question.

Related Questions

Trying to convert Total Return in a dataframe from Object type to float64 type. Not working.

Using Reuters Pricing Formula in Python

Request Intraday Forex Data using Python API.

Issue while requesting Stock Returns (TR.TotalReturn1D)

[Eikon Python API] Can I specify the source from which I want to retrieve data?

  • Feedback
  • Copyright
  • Cookie Policy
  • Privacy Statement
  • Terms of Use
  • Careers
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Alpha
  • App Studio
  • Block Chain
  • Bot Platform
  • Calais
  • Connected Risk APIs
  • DSS
  • Data Fusion
  • Data Model Discovery
  • Datastream
  • Eikon COM
  • Eikon Data APIs
  • Electronic Trading
    • Generic FIX
    • Local Bank Node API
    • Trading API
  • Elektron
    • EMA
    • ETA
    • WebSocket API
  • Legal One
  • Messenger Bot
  • Messenger Side by Side
  • ONESOURCE
    • Indirect Tax
  • Open PermID
    • Entity Search
  • Org ID
  • PAM
    • PAM - Logging
  • ProView
  • ProView Internal
  • Product Insight
  • Project Tracking
  • Refinitiv Data Platform
    • Refinitiv Data Platform Libraries
  • Rose's Space
  • Screening
    • Qual-ID API
    • Screening Deployed
    • Screening Online
    • World-Check One
    • World-Check One Zero Footprint
  • Side by Side Integration API
  • TR Knowledge Graph
  • TREP APIs
    • CAT
    • DACS Station
    • Open DACS
    • RFA
    • UPA
  • TREP Infrastructure
  • TRIT
  • TRKD
  • TRTH
  • Thomson One Smart
  • Transactions
    • REDI API
  • Velocity Analytics
  • Wealth Management Web Services
  • World-Check Data File
  • Explore
  • Tags
  • Questions
  • Badges