newsAPI

FREEMIUM
By Strata Consulting LLC | Updated a month ago | News, Media
Popularity

9.6 / 10

Latency

2,501ms

Service Level

100%

Health Check

N/A

Followers: 4
Resources:
Product Website Terms of use
API Creator:
Rapid account: Strata Consulting LLC
Strata Consulting LLC
strataconsultingllc
Log In to Rate API
Rating: 5 - Votes: 1

README

> โญ Hint: See the Tutorials Section for more walk-throughs

> ๐Ÿš€ Contact us to spotlight your app on this page!

> ๐Ÿ‘ Hire us to build an API for you at www.StrataConsultingLLC.com

newsAPI Developer Guide

Introduction

NewsAPI is a premium data provider, delivering real time news from the highest quality sources at a lower price than other news APIs. News results and search functionality are powered by Google News. This means newsAPI provides news for 141 regions and 41 languages.

What is the difference between newsAPI and others?

newsAPI provides more data points than other news APIs. Not only do you get hundreds of high quality news headlines per request, but newsAPI also nests related news articles within each result (if available). Additionally, newsAPI provides a topic id for each result that you can use to get more in-depth coverage of a specific news story. newsAPI also provides the image url for the logo of the source publisher as well as the image URL for the article itself. This is all in addition to providing the article title, link, publisher domain, date, and a flag to indicate if the article is a video.

Search

Optional Keyword Search Filters:

Include these as part of your query parameter (see example below).
You can include any combination of these terms in your search query to filter the results.

  • after: Search for articles published after a certain date. Example: Politics+after:2020-12-31
  • before: Search for articles published before a certain date. Example: Politics+before:2020-12-31
  • intitle: Restrict results to articles that contain a particular word in the title. Example: intitle:Politics
  • allintitle: Restrict results to articles that contain all of the query words in the title. Example: allintitle:Elon+Musk+Buys+Twitter
  • intext: Restrict results to articles that contain a particular word in the body of the story. Example: intext:Festival
  • allintext: Restrict results to articles that contain all of the query words in the body of the story. Example: allintext:Chicago+Mayoral+Race
  • inurl: Restrict results to a specific news publisher or set of publishers by filtering the articlesโ€™ url domain. Example: inurl:Tribune or inurl:www.cnn.com

You can combine filters as well. For example, to search for articles within a specific time range published by CNN:
after:2016-12-31+before:2020-12-31+inurl:www.cnn.com

Here is a full example:

GET https://newsapi90.p.rapidapi.com/search?query=coronavirus+before:2020-12-31

Search by Topic Id:

Topic idโ€™s are hashed strings generated by Google News which represent news stories or general news categories. They generally look something like this:

CAAqJggKIiBDQkFTRWdvSUwyMHZNRFZxYUdjU0FtVnVHZ0pWVXlnQVAB

Usually, article data that you request from newsAPI will include a topicId field in the response object. You can use this id with the /topic endpoint to find articles that are related to that news story.

Here is an example:

GET https://newsapi90.p.rapidapi.com/topic/{topicId}

You can also provide the topicId as a query parameter instead:

GET https://newsapi90.p.rapidapi.com/topic?topicId={topicId}

Note: If you provide the topicId in both the url path and the query parameter, the url path will take precedence. It is not necessary (or recommended) to provide it in both places.

Categories

If you do not know a specific topicId, you can use one of the following pre-defined general categories instead. The options are:

  • latest
  • world
  • business
  • technology
  • entertainment
  • science
  • sports
  • health

For example:

GET https://newsapi90.p.rapidapi.com/topic/technology

Get Trending Topics

Trending topics are sourced from Google Trends.
This can be accessed by calling the /trendingTopics endpoint. It requires no parameters. The resulting list usually contains approximately 20 items.

This endpoint returns a list of currently trending topics, however it does not include the associated topicId. Therefore, if you are going to use this data to search for news related to a trending topic, you could use newsAPIโ€™s /search endpoint, and provide the topic as a keyword in your query parameter.

Here is an example:

// Get the results from the trendingTopics endpoint:
GET https://newsapi90.p.rapidapi.com/trendingTopics

// Returns ["topic_1", "topic_2", "topic_3" ...]

// Get more news for the topic you are interested in:
GET https://newsapi90.p.rapidapi.com/search?query=topic_1

Get News for Other Regions and Languages

newsAPI is able to provide news for 141 regions in 41 languages.

Language Parameter

This is an optional query parameter. If left blank, it will default to U.S. English (en-US).

The available language codes can be found at this link: Google Language Codes

Here is an example of how you would make a query for latest news in French:

GET https://newsapi90.p.rapidapi.com/topic/latest?language=fr

Region Parameter

This is an optional query parameter. If left blank, it will default to the United States (US).

The available region codes can be found at this link: Google Region Codes

Here is an example of how you would make a query for latest news from Brazil:

GET https://newsapi90.p.rapidapi.com/topic/latest?region=BR