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

How to get 'Exact Match' results with get_news_headlines function

I want to get 'Exact Match' news headlines with get_news_headlines function.

For example, following code has no returns

# import eikon as ek

# ek.get_news_headlines(query='BOJ offers to buy')

(We can find news headlines including this query on Eikon desktop)

Are there any grammar of query to recognize strings without interpretation?

eikoneikon-data-apipythonrefinitiv-dataplatform-eikonworkspaceworkspace-data-api
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.

Upvotes
Accepted
18.2k 21 13 21

Hi @hisashi_oda

I would like to provide additional information to @jirapongse.phuriphanvichai's answer.

1. You can use this tutorial to get to know more on the search grammar.

1.1 Go to Eikon Desktop >> Eikon Menu button >> My App >> News Monitor

1.2 Press F1

1.3 Follow this picture to get information and sample on the exact term search.

You can also check on other search grammar, expression, etc.. in this document.

1.4 I would suggest to use this News Monitor app to test your search query.

In your example, you would get this query as "BOJ offers to buy" (inclusive of both double quotes)

2. The API calls, The API News Query service endpoints expects JSON format query.

Hence, you need to escape these character in your search query.

So "BOJ offers to buy" becomes \"BOJ offers to buy\"

And \"BOJ offers to buy\" becomes \\\"BOJ offers to buy\\\"

As explained with color in this picture.


ahs1.png (124.5 KiB)
ahs2.png (244.5 KiB)
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.

Upvotes
78.8k 250 52 74

@hisashi_oda

Please try this one:

df = ek.get_news_headlines(query="\\\"BOJ offers to buy\\\"")
df

It returns:


news.png (41.1 KiB)
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.