Quick Start guide for Mac OS
Last update Sept 2020
Operating System Mac OS
Interpreter Python 3.5 or higher
Desktop version Refinitiv Workspace - All

Start using the Eikon Data API for Python in 4 steps

  1. Run the Refinitiv Workspace application
  2. Create an App Key for your application
  3. Install the Python library for Eikon Data API
  4. Let's have some fun!

 

1. Run the Refinitiv Workspace application

The Refinitiv Workspace desktop application integrates a Data API proxy that acts as an interface between the Eikon Data API Python library and the Refinitiv Workspace Platform. For this reason, the Refinitiv Workspace application must be running when using the Eikon Data API Python library. When launched, the Refinitiv Workspace application starts listening for local WebSocket connections on port 9000 or the next available port if port 9000 is already occupied. You need to have a valid user account to be able to launch the Refinitiv Workspace application.

2. Create an App Key for your application

Every application using the Eikon Data API must identify itself using an Application Key or App Key for short. The App Key, which is a unique identifier for your application, must be created using the App Key Generator app. Here is how to launch the app and create an App Key for a new application:

  • In the Refinitiv Workspace toolbar type "App Key" and run the App Key Generator app:
  • In the App Key Generator app indicate the name of your new application, the APIs it uses and click on the "Register New App" button:
  • Read the "Terms & Conditions" and click on the "Accept" button
  • Copy the App Key that you will use later in your new application:

3. Install the Python library for Eikon Data APIs

The Eikon Data API Python library is an ease-of-use library, which conveniently wraps the raw message transcription between Refinitiv Workspace and Python providing user-friendly data retrieval calls. The data output from the Python library for the Eikon Data API is available as Pandas DataFrames or as JSON objects.

Run the following command to install the Eikon Data API package from the Python Package Index (PyPI):

    	
            
pip install eikon

Note: This command must be run at the prompt of the command-line interpreter (CMD). If the "Script/" folder of your Python installation is not included in your PATH environment variable, you may even have to navigate to this folder before you run the pip command.

Below is an example of the expected output

    	
            

C:\>

C:\>cd Python36-32\Scripts

C:\Python36-32\Scripts>pip install eikon

Collecting eikon

  Using cached eikon-0.1.11-py3-none-any.whl

Collecting websocket-client (from eikon)

  Using cached websocket_client-0.46.0-py2.py3-none-any.whl

...

Installing collected packages: six, websocket-client, zope.interface, pytz, date

time, appdirs, numpy, python-dateutil, pandas, certifi, chardet, idna, urllib3,

requests, eikon

Successfully installed appdirs-1.4.3 certifi-2018.1.18 chardet-3.0.4 datetime-4.2 eikon-0.1.11 idna-2.6 numpy-1.14.0 pandas-0.22.0 ython-dateutil-2.6.1 pytz-2017.3 requests-2.18.4 six-1.11.0 urllib3-1.22 websocket-client-0.46.0 zope.interface-4.4.3

C:\Python36-32\Scripts>

4. Let's have some fun !

Launch Python IDE and try the following commands.

Initialize the Eikon object. Replace '8e5a3xxxxxxxxxxxxxxxxxxxxxxxxxxxx21b031c' with the App Key generated in step 2.

    	
            

import eikon as ek

ek.set_app_key('8e5a3xxxxxxxxxxxxxxxxxxxxxxxxxxxx21b031c')

Note: In earlier versions of the Python library for Eikon Data APIs, the set_app_key function was called set_app_id. The set_app_id function is now deprecated but still works. If you use an earlier version of the Python library you can call set_app_id to set the App Key of your application.

Great, you have imported the library and set the App Key of your application. You are now ready to send data retrieval requests.

The following instruction retrieves news headlines on Deutsche Lufthansa AG (equity RIC: LHAG.DE), between 09:00 and 18:00 GMT on the 15th of Apr 2019.

    	
            
ek.get_news_headlines('R:LHAG.DE', date_from='2019-03-15T09:00:00', date_to='2019-03-15T18:00:00')

out:

  versionCreated text storyId sourceCode
2019-03-15 16:35:55.731 2019-03-15 16:35:55.731 Tagesvorschau 18.03.2019 urn:newsml:reuters.com:20190315:nAWP3vd2n8:1 NS:AWP
2019-03-15 14:40:56.000 2019-03-15 15:19:15.000 SunExpress Boeing 737 MAX siparişlerinde karar... urn:newsml:reuters.com:20190315:nL8N2124TT:1 NS:RTRS
2019-03-15 14:53:31.000 2019-03-15 14:53:31.000 SunExpress sticks to Boeing 737 MAX orders des... urn:newsml:reuters.com:20190315:nFWN2120AN:1 NS:RTRS
2019-03-15 14:53:04.000 2019-03-15 14:53:04.000 FIRMEN-BLICK-Ferienflieger SunExpress hält an ... urn:newsml:reuters.com:20190315:nL8N2124UW:1 NS:RTRS
2019-03-15 12:28:02.876 2019-03-15 12:28:02.876 Austrian Airlines: Annual results 2018: Passen... urn:newsml:reuters.com:20190315:nNRA880x8g:1 NS:ENPNWS
2019-03-15 12:28:02.318 2019-03-15 12:28:02.318 Traffic results for February 2019: More Than 8... urn:newsml:reuters.com:20190315:nNRA880x8j:1 NS:ENPNWS
2019-03-15 12:28:02.299 2019-03-15 12:28:02.299 Lufthansa Group to Buy 20 Boeing 787 Dreamline... urn:newsml:reuters.com:20190315:nNRA880x7p:1 NS:ENPNWS
2019-03-15 12:05:06.205 2019-03-15 12:05:06.205 Lufthansa to buy 40 long-haul aircraft to redu... urn:newsml:reuters.com:20190315:nNRA880mz3:1 NS:DATMTR
2019-03-15 10:38:43.685 2019-03-15 10:38:43.685 DJ Why Flag Carriers Struggle to Create Low-Co... urn:newsml:reuters.com:20190315:nDJR15tblb:2 NS:DJN
2019-03-15 09:03:35.394 2019-03-15 09:03:35.394 Lufthansa und Wirecard-Aktie knicken ein urn:newsml:reuters.com:20190315:nNRA87z2u9:1 NS:DERSPI

Now, let's display the latest news story satisfying the news search expression "EU AND POL", which represents news on the European Union politics.

First, retrieve the news headlines using the search expression, then get the story ID from the response and finally request the story.

    	
            

headlines = ek.get_news_headlines('EU AND POL',1)

story_id = headlines.iat[0,2]

ek.get_news_story(story_id)

The output is the HTML of the news story.

 

The following commands return time series of daily price history for Microsoft Corp ordinary share between 1st of Jan and 10th of Jan 2016.

    	
            

df = ek.get_timeseries(["MSFT.O"], 

                       start_date="2016-01-01",  

                       end_date="2016-01-10")

df

out:

MSFT.O HIGH CLOSE LOW OPEN COUNT VOLUME
Date            
2016-01-04 54.8000 54.80 53.39 54.32 272781.0 53777963.0
2016-01-05 55.3900 55.05 54.54 54.93 180637.0 34079674.0
2016-01-06 54.4001 54.05 53.64 54.32 225856.0 39518863.0
2016-01-07 53.4850 52.17 52.07 52.70 303271.0 56564852.0
2016-01-08 53.2800 52.33 52.15 52.37 261949.0 48753969.0

The following commands retrieve fundamental data - Revenue and Gross Profit - for Google, Microsoft abd Facebook

    	
            

df, err = ek.get_data(['GOOG.O','MSFT.O', 'FB.O'], 

                      [ 'TR.Revenue','TR.GrossProfit'])

df

out:

  Instrument Revenue Gross Profit
0 GOOG.O 90272000000 55134000000
1 MSFT.O 85320000000 52540000000
2 FB.O 27638000000 23849000000

You can specify additional parameters and request full year revenue and gross profit for the last two years scaled to millions and converted to Euros. E.g.

    	
            

df, err = ek.get_data(['GOOG.O', 'MSFT.O', 'FB.O', 'AMZN.O', 'TWTR.K'], 

                      ['TR.Revenue.date','TR.Revenue','TR.GrossProfit'],

                      {'Scale': 6, 'SDate': 0, 'EDate': -2, 'FRQ': 'FY', 'Curn': 'EUR'})

df

out:

  Instrument Date Revenue Gross Profit
0 GOOG.O 2016-12-31T00:00:00Z 85866.726400 52443.460800
1 GOOG.O 2015-12-31T00:00:00Z 69050.621090 43116.928250
2 GOOG.O 2014-12-31T00:00:00Z 54559.726650 33634.735200
3 MSFT.O 2016-06-30T00:00:00Z 76837.485600 47316.473200
4 MSFT.O 2015-06-30T00:00:00Z 84041.390600 54370.953940
5 MSFT.O 2014-06-30T00:00:00Z 63423.691530 43645.649550
6 FB.O 2016-12-31T00:00:00Z 26289.265600 22685.168800
7 FB.O 2015-12-31T00:00:00Z 16508.281680 13868.319410
8 FB.O 2014-12-31T00:00:00Z 10305.018900 8525.241450
9 AMZN.O 2016-12-31T00:00:00Z 129350.834400 45393.166400
10 AMZN.O 2015-12-31T00:00:00Z 98532.194860 32555.237550
11 AMZN.O 2014-12-31T00:00:00Z 73561.930200 21687.989400
12 TWTR.K 2016-12-31T00:00:00Z 2406.173593 1519.426905
13 TWTR.K 2015-12-31T00:00:00Z 2042.386046 1370.879829
14 TWTR.K 2014-12-31T00:00:00Z 1159.791603 790.850268

You can also mix fundamental data with a snapshot of market data.

    	
            

df, err = ek.get_data(['VOD.L', 'FB.O'], 

                      [ 'TR.Revenue', 'TR.GrossProfit', 'CF_LAST'])

df

Out:

  Instrument Revenue Gross Profit CF_LAST
0 VOD.L 55945230741 14388764346 203.1992
1 FB.O 27638000000 23849000000 140.78

For further information visit the Tutorials section