get_news_headlines how to properly use the criterias?

Hello,


I am using the get_news_headlines,

I am trying to identify news as below, but it doesnt show any result, could you please help me to write properly my query ?

df = ek.get_news_headlines("(hurricane OR tropical storm) AND (oil OR Gulf Coast)")


Thanks in advance.

Best Answer

  • Hi @emmanuel.chaslin Thanks for your question. The get_news_headlines API call uses a query syntax that can be generated from the NEWS app. (Type NEWS into search bar) - I have written an article on how to generate the query from natural language. You can use topic codes or keywords or languages etc - all options appear when you type something into the news query bar, note keywords must be properly escaped by adding another set of "" around those terms - see the ""oil"" term below.

    df = ek.get_news_headlines("( Topic:WND) AND (""oil"" OR Topic:PADD3 )")
    df 

    image

    I hope this can help.

Answers