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

Overview |  Quickstart |  Documentation |  Downloads |  Tutorials |  Articles

question

Upvotes
Accepted
2 0 0 3

How to set sources for get_news_headlines

I'm currently using the the following query:

headlines = ek.get_news_headlines('R:EQNR.OL and Language:LEN', date_from='2018-08-21T00:00:00', date_to='2018-09-21T12:00:00', count=15)

but would like to specify which news sources to include. Is there any way to do this?

or more conveniently, translate query filter made in eikon newsroom to api calls?

eikoneikon-data-apiworkspaceworkspace-data-apirefinitiv-dataplatform-eikonpython
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
38.1k 71 35 53

The get_news_headlines method of Eikon Data API Python (0.1.13) can only retrieve news headlines from the NewsWire source. To get headlines from the NewsRoom source, the application needs to create a custom request and then send it through the send_json_request method. For example:

headlines = ek.send_json_request("News_Headlines", 
                                 {
                                     'number': '15', 
                                     'query': 'R:EQNR.OL and Language:LEN',
                                     'dateFrom':'2018-08-21T00:00:00',
                                     'dateTo':'2018-09-21T12:00:00',
                                     'repository':'NewsRoom'
                                 }
                                )

The above request specifies the NewsRoom source in the repository property. You can also specify both NewsRoom and NewsWire in the repository property ('repository':'NewsRoom, NewsWire').

However, the send_json_request method returns raw JSON data, not a data frame. From the response, the storyId of the NewsRoom headline is prefixed with 'urn:newsml:newsroom'.

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.

This can be converted into the same data frame returned by get_news_headlines() with:

headlines = ek.send_json_request("News_Headlines", ...)
df = ek.news_request.get_data_frame(headlines)
Upvote
39.2k 75 11 27

@markusrk
I think what you may have meant is how you specify newswire sources in your news search expression or more generally how you build a news search expression for use in get_news_headlines method. If this is the case, the answer is you can build a news search expression using the GUI helpers in News Monitor app in Eikon. And then you can copy & paste it into your Python code. To copy the news search expression from the News Monitor app in Eikon highlight the content of the command/search bar in the app, which will then display the string representation of the news search expression, which you can use in get_news_headlines method.


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

@deepali.kumar one more for reference if this is what you are looking for.

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