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

Overview |  Quickstart |  Documentation |  Downloads |  Tutorials |  Articles

question

Upvotes
Accepted
1 0 1 1

cannot run API in python

capture.pngHi,


I can run RIC in both eikon desktop and Eikon add-in. But cannot run it in python.


It kept running without any outputs.


see screenshot

regards,

ray


eikoneikon-data-apiworkspaceworkspace-data-apirefinitiv-dataplatform-eikonpython
capture.png (38.0 KiB)
icon clock
10 |1500

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

Upvotes
Accepted
20.3k 73 10 20

Hi @rayr.hou

Thanks for getting back with the above details.

Based on the error message, this is the same scenario as reported and diagnosed prevoiusly in Trying to execute code from CODEBOOK to a python file, ERROR "Your request is prohibited because the request is on loopback from external IP." - Forum | Refinitiv Developer Community

As explained by my colleague @Alex Putkov. in the above post,

What's happening is that, even though the HTTP request is directed to the localhost, your HTTP proxy intercepts it. After intercepting the request the proxy returns the request to your machine, but now to Eikon API Proxy the request appears as coming from a remote machine (as it comes from the IP address of the HTTP proxy). Eikon API Proxy rejects the request with the error message that you've seen because it only allows the requests coming from the same machine.

Therefore, you will need to speak to your internal network team/security team to configure your proxy settings to allow HTTP requests directed to the localhost to not be intercepted by your HTTP proxy.

If they need assistance with doing this, I recommend they contact the Refinitiv Eikon Helpdesk - which can be done directly from within Eikon OR via My.Refinitiv

icon clock
10 |1500

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

Upvotes
1.7k 2 4 7

Hi @rayr.hou ,

I can run it properly on both Python in the Command Prompt and using Jupyter Notebook, would you mind retry running the code again? and then maybe try to print the df again after your current code is executed.

Please tell me in case the issue still persist, I'll try to do the further investigation.

1631702540762.png

1631702551826.png


1631702540762.png (40.2 KiB)
1631702551826.png (18.4 KiB)
icon clock
10 |1500

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

Upvotes
1 0 1 1

@raksina.samasiri

I reran the code and df seems not executed so that i cannot print df. I am using pycharm.

icon clock
10 |1500

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

Upvotes
1.7k 2 4 7

hi @rayr.hou ,

can you try put print(df) instead of just df, to print the value out on PyCharm console

1631704408562.png

hope this could help.


1631704408562.png (37.3 KiB)
icon clock
10 |1500

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

1631704822528.png

I tried to run df first, but it seems not executed. i had been letting it for the whole morning.....

1631704899589.png

I found some problems showing in pycharm, but not sure if it can explain why df is not being executed...



1631704822528.png (23.7 KiB)
1631704899589.png (15.7 KiB)
Upvote
20.3k 73 10 20

Hi @rayr.hou

Please rename your eikon.py file to something else e.g. eikontest.py

This will allow the import eikon command to import the eikon library correctly.

icon clock
10 |1500

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

I tried and no problems were showing. But df was still not executing.
Upvotes
20.3k 73 10 20

Hi @rayr.hou

Please try the following:

import eikon as ek
import logging
ek.set_app_key('your app key')
ek.set_log_level(logging.DEBUG)
ek.__version__

df=ek.get_timeseries('MSFT.O',start_date='2016-01-01',end_date= '2016-01-10',raw_output=True)

print(df)

And then paste the output here - excluding the x-tr-applicationid value and 'Authorization': 'Bearer ....' data - do not include those as they are confidential.


icon clock
10 |1500

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

hi @rayr.hou ,

your original comment has been removed as it contains the app key, here's what you posted without the confidential data.

1631716586605.png

1631716586605.png (111.2 KiB)
Upvotes
20.3k 73 10 20

Hi @rayr.hou

If you see no further output beyond what you have posted above, it would indicate you are not getting any response from the Eikon API Proxy

Please try the following in a browser and see what response you get for each:

127.0.0.1:9000/api/status

127.0.0.1:9060/api/status

If you can clear the Cache on Eikon and restart Eikon to see if that helps - you can find the Clear Cache option in your Window Start menu under Thomson Reuters / Refinitiv -> Eikon Tools.


icon clock
10 |1500

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

both shows

{"statusCode":"ST_PROXY_READY","version":"2.9.0"}
Upvotes
20.3k 73 10 20

Hi @rayr.hou

I would also recommend you upgrade to the later Eikon library

pip install eikon==1.1.12

and also change the earlier code snippet order

import eikon as ek
ek.set_log_level(1)
ek.set_app_key('your app key')
ek.__version__
df=ek.get_timeseries('MSFT.O',start_date='2016-01-01',end_date= '2016-01-10')
print(df)


icon clock
10 |1500

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

After clear the Cache and upgrade to the later library, it shows below when i ran the code you provided

import eikon as ek

ek.set_log_level(1)

ek.set_app_key('appkey')

2021-09-15 21:11:01,863 P[15836] [MainThread 17872] Send GET request to http://127.0.0.1:9060/api/status to detect API Proxy...

2021-09-15 21:11:01,864 P[15836] [MainThread 17872] Request to http://127.0.0.1:9060/api/status

headers = {'x-tr-applicationid': 'appkey'}

params = None

2021-09-15 21:11:01,925 P[15836] [MainThread 17872] HTTP request response 400: <HEAD><TITLE>Request on loopback from external IP</TITLE></HEAD>

<BODY BGCOLOR="white" FGCOLOR="black"><H1>Request on loopback from external IP</H1><HR>

<FONT FACE="Helvetica,Arial"><B>

Description: Your request is prohibited because the request is on loopback from external IP.</B></FONT>

<HR>

<!-- default "Request on loopback from external IP" response (400) -->

</BODY>

2021-09-15 21:11:01,926 P[15836] [MainThread 17872] Port 9060 was retrieved from .portInUse file

2021-09-15 21:11:01,926 P[15836] [MainThread 17872] Try to handshake on url http://127.0.0.1:9060/api/handshake...

2021-09-15 21:11:01,927 P[15836] [MainThread 17872] Request to http://127.0.0.1:9060/api/handshake

headers = {'Content-Type': 'application/json', 'x-tr-applicationid': 'appkey'}

params = None

2021-09-15 21:11:01,967 P[15836] [MainThread 17872] HTTP request response 400: <HEAD><TITLE>Request on loopback from external IP</TITLE></HEAD>

<BODY BGCOLOR="white" FGCOLOR="black"><H1>Request on loopback from external IP</H1><HR>

<FONT FACE="Helvetica,Arial"><B>

Description: Your request is prohibited because the request is on loopback from external IP.</B></FONT>

<HR>

<!-- default "Request on loopback from external IP" response (400) -->

</BODY>

2021-09-15 21:11:01,967 P[15836] [MainThread 17872] Response : 400 - <HEAD><TITLE>Request on loopback from external IP</TITLE></HEAD>

<BODY BGCOLOR="white" FGCOLOR="black"><H1>Request on loopback from external IP</H1><HR>

<FONT FACE="Helvetica,Arial"><B>

Description: Your request is prohibited because the request is on loopback from external IP.</B></FONT>

<HR>

<!-- default "Request on loopback from external IP" response (400) -->

</BODY>



2021-09-15 21:11:01,967 P[15836] [MainThread 17872] Response 400 on handshake port 9060 : <HEAD><TITLE>Request on loopback from external IP</TITLE></HEAD>

<BODY BGCOLOR="white" FGCOLOR="black"><H1>Request on loopback from external IP</H1><HR>

<FONT FACE="Helvetica,Arial"><B>

Description: Your request is prohibited because the request is on loopback from external IP.</B></FONT>

<HR>

<!-- default "Request on loopback from external IP" response (400) -->

</BODY>

2021-09-15 21:11:01,967 P[15836] [MainThread 17872] Application ID: appkey

2021-09-15 21:11:01,968 P[15836] [MainThread 17872] Init a Desktop session with new app_key

2021-09-15 21:11:01,968 P[15836] [MainThread 17872] Port 9060 on local proxy was detected

Click below to post an Idea Post Idea