DEV Community

Cover image for Simple News API to implement News Data into your website/app
Vineet Prasad
Vineet Prasad

Posted on • Updated on

Simple News API to implement News Data into your website/app

The delivery of news is essential for keeping readers engaged on your website, regardless of its focus. The news source can be created and written by you, or you can use the News API to send news directly to your readers via a website or app.

The NewsData.io News API, which connects to news from prominent premium outlets and offers a free tier, can revolutionize audience engagement.

Best API for News

You may require a News API that offers breaking news with live news tracking. APIs allow the integration of a variety of data into applications and websites. It is essentially software that pipes the data you provide into your code and is known as an application programming interface.

As mentioned above NewsData.io is the best news API as it extracts news information from all the major trusted sources such as BBC news, The New York Times, and 20,000 other trusted sources.

Features of NewsData

To begin, it provides breaking news 24-hour news coverage as well as historical news data from past 2 years gives access to news data articles, trends, and headlines from across the world. There are more than a few vendors. More than 15,000 media outlets submit data into the Newsdata API from sources in 150+ countries. Updates may be as often as minute by minute, and they are automated in 77 languages.

Image description
You can download the data in the form of Excel and JSON format. NewsData.io also offers a free plan to try their API for free.

Pricing Plan

The first choice is free. It allows you to make 200 API calls per day and access all 15,000+ news sources in all 77 languages. However, news outlets deliver delayed headlines. The free option is perfect for any development or testing projects. The NewsData essentially provides you with enough calls to develop your website or app without paying for the whole service.

The regular plan costs $99.99 per month or you can save 20% if you opt yearly plan. It includes 20,000 API requests per month. It also offers professional and corporate plans which cost $199.99 and $599.99 respectively.

How to Integrate NewsData API

You immediately have access to the dashboard once you’ve sign up for the NewsData API. You will find comprehensive documentation on API access keys, API endpoints, and the NewsData API's implementation and development methods. To know more about the integration process you can visit the respective article here.

If you intend to connect the NewsData API with your website or app, you must first determine which languages are supported. There are two primary development languages that may be used:

Python and PHP

The particular parameter codes for the nation, language, search phrase, and news category are present in the documentation folder on the Newsadata website you can thoroughly check them out.

How To Make Your First Request

When you get the API key, you can bring the information utilizing the Programming interface key in the solicitation URL.

To get the data in JSON format, you can use platforms like Curl or HTTP REST clients like Postman.

An illustration of a request to retrieve news articles is as follows:

This request will look for the most recent news articles that include the keyword "pizza" at https://newsdata.io/api/1/news?apikey=YOUR_API_KEY&q=pizza. The apikey boundary is utilized to validate your record and is expected in all solicitations.

You can likewise utilize extra boundaries to refine your hunt, for example, determining a language, classification, space name, and so on.

GET https://newsdata.io/api/1/archive?apikey=YOUR_API_KEY&q=example&language=en&from_date=2023-01-19&to_date=2023-01-25
This request will look for news articles written in English that include the keyword "pizza" and were published between the dates of January 25, 2023, and August 26, 2022.

You will receive a response in JSON format containing the news articles that meet your search criteria once you have submitted a request.

Present Your Readers With Breaking News

No matter what industry you're in, the NewsData API has the potential to give your website or application a big headline. It's a cost-effective option that works for everyone thanks to subscriptions and free versions for each development level.

The API supports PHP and Python, ensuring compatibility with virtually every online project. APIs, along with robust support and documentation, deliver precisely the kind of news your audience is looking for thanks to a wealth of parameters.

API Documentation

For a more detailed description, you can visit our documentation page, in the API endpoints section where you can see how can you integrate your application with crypto news, the latest news, archive news, and news sources. Sources endpoint gives names of haphazardly chosen 100 spaces from a nation, classification, or/and language.

It is primarily a convenience endpoint that you can use to monitor the API's publishers. Example Queries
1. News sources that show from a specific country
https://newsdata.io/api/1/sources?apikey=YOUR_API_KEY&country=ru,ua
2. News sources that show from a specific category
GEThttps://newsdata.io/api/1/sources?apikey=YOUR_API_KEY&category=politics,world
3. News sources that show from specific language
GEThttps://newsdata.io/api/1/sources?apikey=YOUR_API_KEY&language=nl,fr

Top comments (0)