mattlisiv / newsapi-python

A Python Client for News API
MIT License
375 stars 130 forks source link

get_top_headlines() not working #75

Closed cap337 closed 1 year ago

cap337 commented 1 year ago

When get_top_headlines() is called in my code, no articles are returned I simply get: {'status': 'ok', 'totalResults': 0, 'articles': []}.

joelubuntu commented 1 year ago

facing same issues 😔

FooBarAUT commented 1 year ago

yes can confirm, only response is {'status': 'ok', 'totalResults': 0, 'articles': []}, if you look into your account it gets counted in the usage report, so the request seems to somehow get lost on the way back?

economy commented 1 year ago

Same issue on our end

mattlisiv commented 1 year ago

Hi, it appears that the language parameter is no longer supported in the top headlines API. This is a new/breaking change introduced by the news API team. I would reach out to them directly. If they say this is intentional, I can remove the default 'en' parameter from the package.

mattlisiv commented 1 year ago

Apparently, NewsAPI changed their language codes and now expect 'en-US' to be the default. This has been updated to allow the 'en-US' country code in a recently published version 0.2.7 .

Please use now:

top_headlines = newsapi.get_top_headlines(language='en-US')