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

Overview |  Quickstart |  Documentation |  Downloads |  Tutorials |  Articles

question

Upvotes
Accepted
1 1 0 0

Eikon "json_requests" incorrect and Eikon Data API has lost access - related to recent update?

I have a pretty simple python script to get Refinitiv Eikon Data into a dataframe.


import eikon as ek
ek.set_app_key('api_key_goes_here') #real key would go here

Instruments = ["USFN3015=TWEB","USFN30151=TWEB","USFN30152=TWEB"]
Fields = [ek.TR_Field('CF_NAME'), ek.TR_Field('COUPN_RATE'), ek.TR_Field('CF_LAST')]

Price_df, err = ek.get_data(Instruments,Fields)
print (Price_df)


It was working from June until yesterday (10/14/2020) - I think it has something to do with Refinitiv being updated since it worked at 9am yesterday, Refinitiv updated at 10am, and now it's not working. The code works if I run it through the Eikon CodeBook console.

When I run it now, I get this error (I've removed some local directory paths):


Traceback (most recent call last):

  File "<ipython-input-2-29e2cc3d3014>", line 1, in <module>
    runfile('Test.py', wdir='')

  File "spydercustomize.py", line 827, in runfile
    execfile(filename, namespace)

  File "spydercustomize.py", line 110, in execfile
    exec(compile(f.read(), filename, 'exec'), namespace)

  File "Test.py", line 7, in <module>
    Price_df, err = ek.get_data(Instruments,Fields)

  File "AppData\Local\Continuum\anaconda3\lib\site-packages\eikon\data_grid.py", line 190, in get_data

    result = eikon.json_requests.send_json_request(_endpoint, payload, debug=debug)
  File "AppData\Local\Continuum\anaconda3\lib\site-packages\eikon\json_requests.py", line 145, in send_json_request

    if network_error:
UnboundLocalError: local variable 'network_error' referenced before assignment


It looks like there are 2 issues:

1. The error handling in the Eikon "json_requests" doesn't seem to work as intended.

2. Somehow the eikon package has lost network access, or can't connect correctly?

I checked windows firewall and Refinitiv Eikon has access. I'm using python 3.7.3 and the eikon package version 1.1.6.post3. Any help on this would be really appreciated. Thank you.

eikoneikon-data-apiworkspaceworkspace-data-apirefinitiv-dataplatform-eikonpythonjsonnetworkingpandasfirewall
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
4.3k 2 4 5

Hi,

A fix is on going in Eikon.
Could you call the support (or your account manager) and ask them to contact me to provide your user account ?
With this way, we'll be able to update your account.

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.

Upvote
4.3k 2 4 5

Hi,

Note sure that 's the root cause as you mention it stopped to work without change, but could you check if you have following dependency versions that cause issue in current eikon lib:

  • httpx 0.15.x or 0.16.x => need to downgrade to 0.14.3 (pip install httpx==0.14.3)
  • nest-asyncio 1.4.x => need to downgrade to 1.3.3 (pip install nest-asyncio==1.3.3)

In addition, it could comes from an update in Eikon Desktop product.
You can clean your Eikon Cache (start All Programs\Thomson Reuters\Thomson Reuters Eikon Tools\Clear Cache) and restart Eikon.

If it doesn't fix your issue, to investigate deeper, could you activate the log in your script to have a full trace ?

  • add environment variable: HTTPX_LOG_LEVEL=trace
  • add ek.set_log_level(1) in your script

then run your script and check errors in output.

NB: the 'UnboundLocalError: local variable 'network_error' referenced before assignment' is fixed in the next version 1.1.7 that will be available by tomorrow on pypi

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 1 0 0

Thank you for your response. I reset the cache and downgraded httpx to 0.14.3 and nest-asyncio to 1.3.3. I also added the environment variable and set the log output. I'm still getting the error but here is more detail. Does this help at all? (I removed the api key from the below output, replaced it with 'key').

2020-10-15 11:06:10,449 P[14584] [MainThread 14588] Reset a Desktop session with new app_key 2020-10-15 11:06:10,453 P[14584] [MainThread 14588] Unlock login_event for streaming session 0 due to stop streaming call 2020-10-15 11:06:10,461 P[14584] [MainThread 14588] Send GET request to http://localhost:9060/api/status to detect API Proxy... 2020-10-15 11:06:10,468 P[14584] [MainThread 14588] Request to http://localhost:9060/api/status         headers = {'x-tr-applicationid': 'key', 'Authorization': 'Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJBcGlWZXJzaW9uIjoiMSIsIkFwcEtleSI6IjFjY2U4YTMxODM0MzQwZDc4YWMzY2U0MjNhZTU0NjhmMjJhMzE4ZmYiLCJBcHBTY29wZSI6InJhcGkiLCJMaWJyYXJ5TmFtZSI6IkVpa29uIFB5dGhvbiBMaWJyYXJ5IiwiTGlicmFyeVZlcnNpb24iOiIxLjEuNi5wb3N0MyIsImlhdCI6MTYwMjc3Mzk2OCwiZXhwIjoxNjAzOTgzNTY4fQ.6Izh_gl_4hvO1oWphE_uv4jNumZydxudTzXHQRXdGPI'}         params = None 2020-10-15 11:06:12,521 P[14584] [MainThread 14588] HTTP request response 200: {"statusCode":"ST_PROXY_READY","version":"2.6.3"} 2020-10-15 11:06:12,528 P[14584] [MainThread 14588] Checking port 9060 response : 200 - {"statusCode":"ST_PROXY_READY","version":"2.6.3"} 2020-10-15 11:06:12,534 P[14584] [MainThread 14588] Port 9060 was retrieved from .portInUse file 2020-10-15 11:06:12,540 P[14584] [MainThread 14588] Try to handshake on url http://localhost:9060/api/handshake... 2020-10-15 11:06:12,545 P[14584] [MainThread 14588] Request to http://localhost:9060/api/handshake         headers = {'Content-Type': 'application/json', 'Authorization': 'Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJBcGlWZXJzaW9uIjoiMSIsIkFwcEtleSI6IjFjY2U4YTMxODM0MzQwZDc4YWMzY2U0MjNhZTU0NjhmMjJhMzE4ZmYiLCJBcHBTY29wZSI6InJhcGkiLCJMaWJyYXJ5TmFtZSI6IkVpa29uIFB5dGhvbiBMaWJyYXJ5IiwiTGlicmFyeVZlcnNpb24iOiIxLjEuNi5wb3N0MyIsImlhdCI6MTYwMjc3Mzk2OCwiZXhwIjoxNjAzOTgzNTY4fQ.6Izh_gl_4hvO1oWphE_uv4jNumZydxudTzXHQRXdGPI', 'x-tr-applicationid': 'key'}         params = None 2020-10-15 11:06:12,706 P[14584] [MainThread 14588] HTTP request response 200: {"access_token":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJBcGlWZXJzaW9uIjoiMSIsIkFwcEtleSI6IjFjY2U4YTMxODM0MzQwZDc4YWMzY2U0MjNhZTU0NjhmMjJhMzE4ZmYiLCJBcHBTY29wZSI6InJhcGkiLCJMaWJyYXJ5TmFtZSI6IkVpa29uIFB5dGhvbiBMaWJyYXJ5IiwiTGlicmFyeVZlcnNpb24iOiIxLjEuNi5wb3N0MyIsImlhdCI6MTYwMjc3NDM3MiwiZXhwIjoxNjAzOTgzOTcyfQ.Gg2iZ9y0acJVOCRBsP733booTG6QRauUfISbYwBqm6M","expires_in":1209600,"token_type":"bearer"} 2020-10-15 11:06:12,712 P[14584] [MainThread 14588] Response : 200 - {"access_token":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJBcGlWZXJzaW9uIjoiMSIsIkFwcEtleSI6IjFjY2U4YTMxODM0MzQwZDc4YWMzY2U0MjNhZTU0NjhmMjJhMzE4ZmYiLCJBcHBTY29wZSI6InJhcGkiLCJMaWJyYXJ5TmFtZSI6IkVpa29uIFB5dGhvbiBMaWJyYXJ5IiwiTGlicmFyeVZlcnNpb24iOiIxLjEuNi5wb3N0MyIsImlhdCI6MTYwMjc3NDM3MiwiZXhwIjoxNjAzOTgzOTcyfQ.Gg2iZ9y0acJVOCRBsP733booTG6QRauUfISbYwBqm6M","expires_in":1209600,"token_type":"bearer"} 2020-10-15 11:06:12,717 P[14584] [MainThread 14588] Application ID: key 2020-10-15 11:06:12,722 P[14584] [MainThread 14588] Init a Desktop session with new app_key 2020-10-15 11:06:12,727 P[14584] [MainThread 14588] Port 9060 on local proxy was detected 2020-10-15 11:06:12,733 P[14584] [MainThread 14588] entity: DataGrid_StandardAsync 2020-10-15 11:06:12,738 P[14584] [MainThread 14588] payload: {'requests': [{'instruments': ['USFN3015=TWEB', 'USFN30151=TWEB', 'USFN30152=TWEB'], 'fields': [{'name': 'CF_NAME'}, {'name': 'COUPN_RATE'}, {'name': 'CF_LAST'}]}]} 2020-10-15 11:06:12,743 P[14584] [MainThread 14588] Request:{'Entity': {'E': 'DataGrid_StandardAsync', 'W': {'requests': [{'instruments': ['USFN3015=TWEB', 'USFN30151=TWEB', 'USFN30152=TWEB'], 'fields': [{'name': 'CF_NAME'}, {'name': 'COUPN_RATE'}, {'name': 'CF_LAST'}]}]}}} 2020-10-15 11:06:12,749 P[14584] [MainThread 14588] Request to http://localhost:9060/api/v1/data         headers = {'Content-Type': 'application/json', 'x-tr-applicationid': 'key', 'Authorization': 'Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJBcGlWZXJzaW9uIjoiMSIsIkFwcEtleSI6IjFjY2U4YTMxODM0MzQwZDc4YWMzY2U0MjNhZTU0NjhmMjJhMzE4ZmYiLCJBcHBTY29wZSI6InJhcGkiLCJMaWJyYXJ5TmFtZSI6IkVpa29uIFB5dGhvbiBMaWJyYXJ5IiwiTGlicmFyeVZlcnNpb24iOiIxLjEuNi5wb3N0MyIsImlhdCI6MTYwMjc3NDM3MiwiZXhwIjoxNjAzOTgzOTcyfQ.Gg2iZ9y0acJVOCRBsP733booTG6QRauUfISbYwBqm6M'}         params = None 2020-10-15 11:06:12,895 P[14584] [MainThread 14588] HTTP request response 302:  2020-10-15 11:06:12,902 P[14584] [MainThread 14588] HTTP Response code: 302 2020-10-15 11:06:12,907 P[14584] [MainThread 14588] HTTP Response:  2020-10-15 11:06:12,913 P[14584] [MainThread 14588] Headers: x_ratelimit_limit=None / x_ratelimit_remaining=None  2020-10-15 11:06:12,918 P[14584] [MainThread 14588]          x_volumelimit_limit=None / x_volumelimit_remaining=None 2020-10-15 11:06:12,924 P[14584] [MainThread 14588]          retry_after 0 Traceback (most recent call last):   File "<ipython-input-7-29e2cc3d3014>", line 1, in <module>     runfile('//cfcltdc01/sharedfiles/Cap Mkts/QRM/Innovient Pricing/Code/Test.py', wdir='//cfcltdc01/sharedfiles/Cap Mkts/QRM/Innovient Pricing/Code')   File "C:\Users\servicing.cardinal\AppData\Local\Continuum\anaconda3\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 827, in runfile     execfile(filename, namespace)   File "C:\Users\servicing.cardinal\AppData\Local\Continuum\anaconda3\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 110, in execfile     exec(compile(f.read(), filename, 'exec'), namespace)   File "//cfcltdc01/sharedfiles/Cap Mkts/QRM/Innovient Pricing/Code/Test.py", line 11, in <module>     Price_df, err = ek.get_data(Instruments,Fields)   File "C:\Users\servicing.cardinal\AppData\Local\Continuum\anaconda3\lib\site-packages\eikon\data_grid.py", line 190, in get_data     result = eikon.json_requests.send_json_request(_endpoint, payload, debug=debug)   File "C:\Users\servicing.cardinal\AppData\Local\Continuum\anaconda3\lib\site-packages\eikon\json_requests.py", line 145, in send_json_request     if network_error: UnboundLocalError: local variable 'network_error' referenced before assignment


One other thing I noticed - before the Refinitiv update yesterday, all requests were going through port 9000, and now the requests are going through port 9060. Here is some old response output that shows the port 9000 and new response code that shows port 9060.

Old (working):

Set App Key: None Response : 500 - {"code":500,"message":"Cannot find module \".\"","statusMessage":"Internal Server Error"} Port 9000 was retrieved from .portInUse file Try to handshake on url http://localhost:9000/api/handshake... Response : 400 - Handshake payload is invalid. Set Proxy port number to 9000 Checking port 9000 response : 500 - {"code":500,"message":"Cannot find module \".\"","statusMessage":"Internal Server Error"} Port 9000 was retrieved from .portInUse file Try to handshake on url http://localhost:9000/api/handshake... Response : 200 - {"access_token":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJBcGlWZXJzaW9uIjoiMSIsIkFwcEtleSI6IjIzYWY3N2VhODFhYzRmYTM5Zjk2M2ZlZWU4MDE5ODQyZGVlMGUzZmIiLCJBcHBTY29wZSI6InJhcGkiLCJMaWJyYXJ5TmFtZSI6IkVpa29uIFB5dGhvbiBMaWJyYXJ5IiwiTGlicmFyeVZlcnNpb24iOiIxLjEuMiIsImlhdCI6MTYwMjE2MjA1NCwiZXhwIjoxNjAzMzcxNjU0fQ.7lOouXEnGeCRj1mwv24katN3_RpbWP74wHePiAW-P90","expires_in":1209600,"token_type":"bearer"} Application ID: key Port 9000 on local proxy was detected


New (not working):

Send GET request to http://localhost:9060/api/status to detect API Proxy... Checking port 9060 response : 200 - {"statusCode":"ST_PROXY_READY","version":"2.6.3"} Port 9060 was retrieved from .portInUse file Try to handshake on url http://localhost:9060/api/handshake... Response : 200 - {"access_token":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJBcGlWZXJzaW9uIjoiMSIsIkFwcEtleSI6IjIzYWY3N2VhODFhYzRmYTM5Zjk2M2ZlZWU4MDE5ODQyZGVlMGUzZmIiLCJBcHBTY29wZSI6InJhcGkiLCJMaWJyYXJ5TmFtZSI6IkVpa29uIFB5dGhvbiBMaWJyYXJ5IiwiTGlicmFyeVZlcnNpb24iOiIxLjEuNi5wb3N0MyIsImlhdCI6MTYwMjc2Njg0MSwiZXhwIjoxNjAzOTc2NDQxfQ.YhKKpHmXggs-60Xd-VedhghNoxWg30nzqWuIRXqShBs","expires_in":1209600,"token_type":"bearer"} Application ID: key Port 9060 on local proxy was detected
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 1 0 0

When I run http://localhost:9000/ping?all I get back a normal response.

{"port":9000,"mode":"eikon4","pid":17284,"hasSecure":true,"startedTime":"Thu Oct 15 2020 11:31:43 GMT-0400 (Eastern Daylight Time)","subApps":[{"path":"/heap"},{"path":"/ping"},{"path":"/sxs","data":{"hasSecure":true,"sxsApps":{}}},{"path":"/api"},{"path":"/sxs/v1/services/messenger"}]}


When I run http://localhost:9060/ping?all I get back an "error" page that says

Cannot GET /ping


In the past, when it was working, I was able to use port 9000 - it was coming from a different ".portInUse" file located here:

C:\Users\user\AppData\Roaming\Thomson Reuters\Eikon API Proxy

Since the update yesterday, though, it's using the ".portInUse" file from this directory
C:\Users\user\AppData\Roaming\Refinitiv\Data API Proxy

I updated the new ".portInUse" file to 9000, but the code is being forced to use port 9060.

2020-10-15 11:35:19,070 P[10700] [MainThread 14836] Port 9000 was retrieved from .portInUse file
2020-10-15 11:35:19,071 P[10700] [MainThread 14836] Try to handshake on url http://localhost:9000/api/handshake...
2020-10-15 11:35:19,073 P[10700] [MainThread 14836] Request to http://localhost:9000/api/handshake
        headers = {'Content-Type': 'application/json', 'x-tr-applicationid': 'key'}
        params = None
2020-10-15 11:35:19,077 P[10700] [MainThread 14836] HTTP request response 307: Temporary Redirect. Redirecting to http://localhost:9060/api/handshake
2020-10-15 11:35:19,079 P[10700] [MainThread 14836] Response : 307 - Temporary Redirect. Redirecting to http://localhost:9060/api/handshake



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,

Don't modify the .portInUse file.

Both 9000 and 9060 port number are used by Eikon, and that's normal if http://localhost:9000/api/handshake is redirected to http://localhost:9060/api/handshake

Once you have "key Port 9060 on local proxy was detected" in your log, that means that python script detected correctly.

Upvotes
1 1 0 0

Here the TRACE info (thought I had uploaded it already). I seem to be getting a similar error to another user here.

https://community.developers.refinitiv.com/questions/67590/unable-to-make-api-calls-since-oct-14-2020-working.html


trace.txt (16.9 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 1 0 0

@ I'm still having the issue - i updated Eikon to 1.1.7.

  File "C:\Users\servicing.cardinal\AppData\Local\Continuum\anaconda3\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 827, in runfile
    execfile(filename, namespace)
  File "C:\Users\servicing.cardinal\AppData\Local\Continuum\anaconda3\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 110, in execfile
    exec(compile(f.read(), filename, 'exec'), namespace)
  File "//cfcltdc01/sharedfiles/Cap Mkts/QRM/Innovient Pricing/Code/QRMPriceDownload1.py", line 179, in <module>
    DataElements_df_1, err = ek.get_data(DataElementInstruments1,DataElements_fields)
  File "C:\Users\servicing.cardinal\AppData\Local\Continuum\anaconda3\lib\site-packages\eikon\data_grid.py", line 192, in get_data
    if result.get('responses'):
AttributeError: 'NoneType' object has no attribute 'get'

It seems like a number of users are having the same issue since Eikon was updated?

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 1 0 0

I also saw other posts related to API errors and ran the "Invoke" requests through powershell


Invoke-WebRequest -Uri "http://127.0.0.1:9060/api/v1/data" -Method POST
Invoke-WebRequest : The remote server returned an error: (302) Redirect.
At line:1 char:1
+ Invoke-WebRequest -Uri "http://127.0.0.1:9060/api/v1/data" -Method PO ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-WebRequest], WebExc
   eption
    + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeWebRequestCommand

Invoke-WebRequest -Uri "http://127.0.0.1:9000/api/v1/data" -Method POST
Invoke-WebRequest : The remote server returned an error: (302) Redirect.
At line:1 char:1
+ Invoke-WebRequest -Uri "http://127.0.0.1:9000/api/v1/data" -Method PO ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-WebRequest], WebExc
   eption
    + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeWebRequestCommand
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 1 0 0

Any update? This seems to be affecting multiple users.

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.

Click below to post an Idea Post Idea