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?

Best Answer

  • chavalit-jintamalit
    Answer ✓

    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.

    image

    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.

    image

Answers