GithubHelp home page GithubHelp logo

Comments (4)

mattlisiv avatar mattlisiv commented on August 25, 2024

Hi @gabrieldespindula ,

I do not believe the language option is an available parameter for the top headlines endpoint. What is the current error you are receiving?

Thanks,
Matt

from newsapi-python.

gabrieldespindula avatar gabrieldespindula commented on August 25, 2024

Hey there, I tested and it does work in some different languages.
My point is just a small improvement.
Currently if you run:
from newsapi import NewsApiClient
newsapi = NewsApiClient(api_key='your key')
top_headlines = newsapi.get_top_headlines()

you get this exception:

Traceback (most recent call last):
File "", line 1, in
File "C:\Python27\lib\site-packages\newsapi\newsapi_client.py", line 119, in get_top_headlines
raise NewsAPIException(r.json())
newsapi.newsapi_exception.NewsAPIException

but if you send
top_headlines = newsapi.get_top_headlines(language='en')
It works just fine.
My suggestion is set 'en' as default language instead of 'None'. Look at newsapi_client.py line 12

Then would be possible to request the headlines without any argument. English language will be the default when sending the API.
And it also prevent new users from receiving this exception.

from newsapi-python.

mattlisiv avatar mattlisiv commented on August 25, 2024

Ok great. I think something may have changed, because this error is new. Either way, I think that is a great idea to default the language.

A PR would be fantastic, or I'll get around to updating it later this week.

Thanks!

from newsapi-python.

mattlisiv avatar mattlisiv commented on August 25, 2024

Corrected with pull request #25 .

from newsapi-python.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.