Upgrade from Eikon -> Workspace. Learn about programming differences.

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

Overview |  Quickstart |  Documentation |  Downloads |  Tutorials |  Articles

question

Upvotes
Accepted
1 4 8 7

How to search headlines with multiple keywords? Why is such an input wrong?

eikoneikon-data-apipythonrefinitiv-dataplatform-eikonworkspaceworkspace-data-apinews
icon clock
10 |1500

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

This query is a duplicate of the one in this comment.

1 Answer

· Write an Answer
Upvote
Accepted
39.4k 77 11 27

@yuyang
You typically don't need to use quotes around keywords. Try

ek.get_news_headlines("Product:IFRFM AND Topic:ISU AND Topic:EUB AND (PRICED OR DEAL)")
The above expression is syntactically correct, but returns an empty dataframe because the news search expression is too narrow and no headlines match it. Try instead for example:
ek.get_news_headlines("Topic:ISU AND Topic:EUB AND (PRICED OR DEAL)")
The reason your original news search expression results in an error is that Python library passes the news search expression string to a JSON object, which is then submitted in HTTP request to the Web service that delivers news headlines. This means that in order to escape a character you first need to escape it for Python and then for JSON. One way to do this is to use triple backslash:
"Topic:ISU AND Topic:EUB AND (\\\"PRICED\\\" OR \\\"DEAL\\\")"
Another is to use Python raw string:
r"Topic:ISU AND Topic:EUB AND (\"PRICED\" OR \"DEAL\")"

But as I said at the beginning the easiest is to not include keywords in quotes at all.

icon clock
10 |1500

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

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

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