Skip to main content

In the fast-paced world of modern journalism, staying ahead of the competition and delivering real-time information is crucial. As technology continues to evolve, so does the way we consume news.

Enter Newsdata.io, a cutting-edge platform that provides developers, data scientists, and businesses with access to the latest news in real-time. In this article, we will tell you all about NewsData.io’s “News” endpoint.

What is Latest News Endpoint of NewsData.io?

The latest news endpoint allows the users to access the latest news up to past 48 hours with using ‘news‘ endpoint. The basic parameter to retrieve the latest news would be

https://newsdata.io/api/1/news?apikey=pub_YOUR API KEY

This parameter would retrieve all the articles of past 48 hours for which paid users will get 50 articles per request which can also be customized as per the request and 10 articles per request for free users. After entering YOUR API KEY you can add the further request parameters such as q, country, language, domain, etc.

Resources

Resources URL

GET https://newsdata.io/api/1/news?apikey=pub_YOUR API KEY

The articles are extracted in JSON format which is bounded by a rate limit and there is a request window limit of 15 minutes in those 15 minutes users are bounded by an 1800 credit limit for paid users.

How to Extract Latest News through the “News” Endpoint

1. Obtain API Key

Before you can make any requests to the API, you’ll need to sign up for an account on Newsdata.io and obtain an API key. The API key is a unique identifier that grants you access to the API’s functionalities and ensures secure communication between your application and Newsdata.io’s servers.

2. Make Your Request

To request the Latest News endpoint, you’ll use an HTTP client library (such as a request in Python) or a tool like Postman and even you can access the data with the search query URL and use it in Chrome. The typical components of the API request include:

a. Endpoint URL: Use the URL obtained from the documentation.
b. Request Method: For retrieving data, use the HTTP GET method.
c. Add Query: You need to add a query of your request https://newsdata.io/api/1/news?apikey=YOUR_API_KEY

Request Parameter of Latest News Endpoints

1. Timeframe: You can search the articles by using specific timeframes. You can set the timeframe between 1 hour to 48 hours and also you can set the timeframe in minutes in which users can search the articles from 1 minute to 2880 minutes. But users can only use any one of the parameter either enter the timeframe in minutes or in hours. For example timeframe=6, it will show the articles past 6 hours and for retrieving the articles of past 1 hour 30 mins the parameter would be timeframe=90m

https://newsdata.io/api/1/news?apikey=pub_YOUR API KEY&q=food&timeframe=2

This query will show the articles of the past 2 hour.

https://newsdata.io/api/1/news?apikey=pub_YOUR API KEY&q=money&timeframe=104m

This query will show the articles of your entered query of the past 104 minutes

2. q: Search news articles of specific keywords anywhere presented in the entire article. For example, q=messi will show all the relevant articles that contain the keyword Messi.

https://newsdata.io/api/1/news?apikey=pub_YOU API KEY&q=movies

This will fetch all the relevant articles that contain the keyword Movies even if it’s between the content or title.

3. qInTitle: This parameter will help users search news articles for specific keywords or phrases present in the news titles only. For example, qInTitle=messi will show all the relevant articles that contain messi in the news title.

https://newsdata.io/api/1/news?apikey=pub_YOU API KEY&qInTitle=football

This request will fetch all the related articles which contain the keyword “football” in the article’s title.

4. qInMeta: Search the news articles from the URL, Meta description, and Title by using this parameter.

https://newsdata.io/api/1/news?apikey=pub_YOU API KEY&qInMeta=money

To know more about how the q, qInTitle, and qInMeta functions you you check out this blog.

5. Country: Search the news articles from a specific country. You can add up to 5 countries in a single query. Check the codes for all the countries here. For example, country=au,jp where au means Australia and jp means Japan

https://newsdata.io/api/1/news?apikey=pub_YOU API KEY&q=elon musk&country=us

This will fetch the articles related to query=elon musk from the mentioned specific country which is USA.

6. Category: Search the news articles for a specific category. You can add up to 5 categories in a single query. Check the codes for all the categories here. For example, category=sports,top there is a total of 12 categories option available from which users can filter.

https://newsdata.io/api/1/news?apikey=pub_YOU API KEY&q=modi&category=politics

This request will fetch the related articles that contain the keyword Modi and are related to the politics category. So if the user enters category=politics the API will fetch the articles related to the politics category.

7. Language: Search the news articles for a specific language. You can add up to 5 languages in a single query. Check the codes for all the languages here. For example, language=fr,en where fr means French and en means English.

https://newsdata.io/api/1/news?apikey=pub_YOU API KEY&q=ronaldo&language=en

This query will fetch only those articles which are in English and to change the language you can check the list accordingly and modify your request.8. Domain: You can search the news articles of specific news domains such as BBC or the New York Times. You can add up to 5 domains in a single query and the request parameter would be domain=bbc,nytimes.

https://newsdata.io/api/1/news?apikey=pub_YOU API KEY&q=money&domain=bbc

This query would fetch the articles that contain the keyword Money which is from the bbc domain only.9. Domainurl: This parameter will allow users to extract articles from news domains. The parameter would be domainurl=nytimes.com,bbc.com,bbc.co.uk. You can add up to 5 domain URLs and if any domain URL is incorrect

https://newsdata.io/api/1/news?apikey=pub_YOU API KEY&q=games&domainurl=bbc.com

10. Exclude Domain: By this parameter, you can exclude the domains in which you dont want relevant articles. The parameter would be excludedomain=nytimes.com,bbc.com
https://newsdata.io/api/1/news?apikey=pub_YOU API KEY&q=games&excludedomain=bbc.com

This request parameter will fetch all the articles that contain the keyword games excluded from BBC domain. This would be helpful for those users who don’t want the articles of any specific domain for example above mentioned is BBC. To clarify this request further here are some more examples.

https://newsdata.io/api/1/news?apikey=pub_YOU API KEY&q=ronaldo&excludedomain=nytimes.com

Which will exclude all the The New York Times news domain articles.

11. Domain Priority: Domain priority allows the users to extract news articles on the basis of domain authority of news sources. We have set the priority on 3 different levels which are top, middle, and low.

  • Top: Fetches news articles from the top 10% of the news domains. Request parameter prioritydomain=top
    https://newsdata.io/api/1/news?apikey=pub_YOU API KEY&q=global warming&prioritydomain=top
  • Medium: Fetches news articles from the top 30% of the news domains. Request parameter prioritydomain=medium
    https://newsdata.io/api/1/news?apikey=pub_YOU API KEY&q=modi&prioritydomain=medium
  • Low: Fetches news articles from the top 50% of the news domains. Request parameter prioritydomain=low
    https://newsdata.io/api/1/news?apikey=pub_YOU API KEY&q=modi&prioritydomain=low

12. Timezone: You can search the articles on the basis of specific time zones. You can add any specific time zone by checking the time zone here. The request parameter for time zone would be timezone=America/New_york.

https://newsdata.io/api/1/news?apikey=pub_YOU API KEY&q=ronaldo&timezone=Asia/Dubai

13. Full Content: By this request parameter users can request a full-content article or without a full-content article. The request parameter of this would be full_content=1 for full content and full_content=0 for which doesn’t contain full-width content.

For Full Content

https://newsdata.io/api/1/news?apikey=pub_YOU API KEY&q=global warming&full_content=1

Without full content
https://newsdata.io/api/1/news?apikey=pub_YOU API KEY&q=global warming&full
_content=0

14. Image: This parameter will allow you to search the articles with or without featured images. To send this request parameter write image=1 to have the articles with images and image=0 for those articles without featured images.

For articles with featured images

https://newsdata.io/api/1/news?apikey=pub_YOU API KEY&q=global warming&image=1

For articles without featured images
https://newsdata.io/api/1/news?apikey=pub_YOU API KEY&q=global warming&image=0

15. Video: This parameter would help users to retrieve videos containing articles. To get the articles containing video the request parameter would be video=1 and for those without video articles, the parameter would be video=0.

For articles with video

https://newsdata.io/api/1/news?apikey=pub_YOU API KEY&q=modi&video=1

For articles without video
https://newsdata.io/api/1/news?apikey=pub_YOU API KEY&q=modi&video=0

16. Size: This parameter allows the users to customize the number of articles that they can obtain from one API request. For free users, the max limit is 10, and for paid users, the limit is up to 50 per request. The parameter for this request would be size=25.

https://newsdata.io/api/1/news?apikey=pub_YOU API KEY&q=money&size=30

This request will fetch 30 articles per request but it is only for paid users because their max limit is up to 50 and for free users the article limit is 10 so for free users the request would be.

https://newsdata.io/api/1/news?apikey=pub_YOU API KEY&q=money&size=10

If free users try to fetch more than the limit of 10 then the request will fail and an error would be displayed.

To extract data from the postman follow these steps:
1. Download and install Postman.
2. Click on the add button.
3. Insert your query.
4. Then send your request.

You will retrieve your data.

You can customize your request using query parameters to specify criteria like keywords, timeframe, sources, categories, and more. Refer to the documentation for the list of available parameters.

Send You API Request

With your API request prepared, send it to Newsdata.io API servers using the appropriate HTTP client or tool. The server will process your request based on the parameters provided and return the response in the specified format JSON.

Handle the Response

With your API request prepared, send it to Newsdata.io API servers using the appropriate HTTP client or tool. The server will process your request based on the parameters provided and return the response.

Leave a Reply