Using get_data() on an API (Not Codebook)

Options

I'm trying to switch on an API, but it seems like the codes i was using in the internal Refinitv codebook app (even simple lines like:

import refinitiv.data as rd
import refinitiv.data as rd
rd.open_session()
df = rd.get_data(
universe = ['AAPL.O'],
fields = ['CF_CLOSE']
)

display(df)

) don't seem to work in the API. Do you if the structure of the call changes in an API ?

Thank you !

Bests,

Victor

Answers

  • Jirapongse
    Jirapongse ✭✭✭✭✭

    @MyScreenName

    Thank you for reaching out to us.

    You can enable the debug log in the API by using the following code in order to verify what the problem is.

    import refinitiv.data as rd
    
    config = rd.get_config()
    config.set_param("logs.transports.file.enabled", True)
    config.set_param("logs.transports.file.name", "lseg-data-lib.log")
    config.set_param("logs.level", "debug")

    rd.open_session()
    df = rd.get_data(
    universe = ['AAPL.O'],
    fields = ['CF_CLOSE']
    )

    display(df)

    With this code, the lseg-data-lib.log file will be created.

    Please ensure all private information is removed from the file before sharing it

  • Hi Jirapongse,

    Thank you for your reply.

    Still not working :/

    An error occurred while requesting URL('http://localhost:9000/api/status').ConnectError('[Errno 99] Cannot assign requested address')An error occurred while requesting URL('http://localhost:9060/api/status').ConnectError('[Errno 99] Cannot assign requested address')Error: no proxy address identified.Check if Desktop is running.An error occurred while requesting URL('http://localhost:9000/api/handshake').ConnectError('[Errno 99] Cannot assign requested address')Error on handshake url http://localhost:9000/api/handshake : ConnectError('[Errno 99] Cannot assign requested address')Session is not opened. Can't send any request
    
    ---------------------------------------------------------------------------ValueError                                Traceback (most recent call last)Cell In[25], line 14      9 config.set_param("logs.level", "debug")     12 rd.open_session()---> 14 df = rd.get_data(     15      16   universe = ['AAPL.O'],     17      18   fields = ['CF_CLOSE']     19      20   )     23 display(df)File /opt/conda/lib/python3.12/site-packages/refinitiv/data/_access_layer/get_data_func.py:63, in get_data(universe, fields, parameters, use_field_names_in_headers)     57     warnings.warn(     58         "Parameter 'use_field_names_in_headers' is deprecated and will be removed in future library version v2.0.",     59         FutureWarning,     60     )     62 session = get_default()---> 63 raise_if_closed(session)     65 logger = session.logger()     67 # Library usage loggingFile /opt/conda/lib/python3.12/site-packages/refinitiv/data/_core/session/tools.py:37, in raise_if_closed(session)     35 error_message = "Session is not opened. Can't send any request"     36 session.error(error_message)---> 37 raise ValueError(error_message)ValueError: Session is not opened. Can't send any request
    

    eventhough it workd for ds.get_data(tickers='NOVOb.CO', fields=(['TR.CommonName']))

  • Jirapongse
    Jirapongse ✭✭✭✭✭

    @MyScreenName

    It looks like that the library can't connect to the desktop session.

    Please refer to the Eikon Data API and Refinitiv Data Library - Troubleshooting article to make sure that the Data API Proxy is running properly.

    image.png