How to translate news monitor query to Python API headlines query? The query is ("Hospital" AND ( "b

Best Answer

  • Hi @alankar.gupta

    With Eikon Data API version 1.1.8

    I just tested this code and this should be the code you are looking for:

    syntax = "Hospital AND ( build OR reopen OR construct OR expansion OR upgrade OR develop OR repurpose OR modern )"
    df = ek.get_news_headlines(syntax)

    df

    image

Answers

  • @alankar.gupta you can double click on the query in NEWS monitor app and it will generate the query string for you which you can copy and paste into the get_news_headlines() API call. Please see my article which goes through this. I hope this can help.

  • Hello Jason. I think i need to convert this to a python format before copy pasting it. That's what i am trying to understand.

    I was trying with this query but it's not working.

    df = ek.get_news_headlines(query="Hospital\\\" AND \\\ ("build\\\" OR \\\"reopen\\\" OR \\\"construct\\\" OR \\\"expansion\\\" OR \\\"upgrade\\\" OR \\\"develop\\\" OR \\\"repurpose\\\" OR \\\"modern\\\" ))

    Can You help me with this?

  • Many Thanks! One last thing. Can we filter news based on most important? We can do that in Eikon Desktop.

    image

  • Hi @alankar.gupta

    I believe that it is not possible to filter by "only important" with ek.get_news_headlines()

    You can run help(ek.get_news_headlines) to see the function description.