News API

Connect to https://newsapi.org/ and get a dataframe

Connect

You must Connect before any other methods

naas_drivers.newsapi.connect("YOUR_API_KEY")
# OR You can use our default apikey to test
# Limited to 200/hours request for all naas users
naas_drivers.newsapi.connect()

Get

Basic

naas_drivers.newsapi.get(q="TSLA")

Fields

Choose fields you want to get in result, list available below:

  • title

  • image

  • link

  • description

  • source

  • image

fields = ["image", "title"]
naas_drivers.newsapi.get(q="TSLA", fields=fields)

Language

Language of news

country = "en"
data = naas_drivers.newsapi.get(q="TSLA", language=country)

Limit

Limit the number of results

limit = 5
data = naas_drivers.newsapi.get(q="TSLA", limit=limit)

Get top news

data = naas_drivers.newsapi.get_top(sources='bbc-news')

Get sources news

sources = naas_drivers.newsapi.get_sources()

Official documentation