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

Overview |  Quickstart |  Documentation |  Downloads |  Tutorials |  Articles

question

Upvotes
Accepted
3 0 0 3

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-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
18k 21 12 20

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 5.0 MiB each and 10.0 MiB total.

Upvotes
38.1k 71 35 53

@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 5.0 MiB each and 10.0 MiB total.

Click below to post an Idea Post Idea