In this article, we will focus on NewsData.io’s “latest” Endpoint.
Latest News Endpoint of NewsData.io
For fetching the latest news, the ‘latest’ endpoint is used. This gives users access to the latest news up to the past 48 hours.
The basic parameter to retrieve the latest news is:
https://newsdata.io/api/1/latest?apikey=YOUR_API_KEY
This parameter retrieves articles from the past 48 hours. Paid users get 50 articles/request and free users get 10 articles/request.
After entering the API key, request parameters such as q, country, language, domain, etc. can also be added.
Latest News Extraction using “latest” Endpoint
1. Obtain API Key
You need to sign up for an account on Newsdata.io and obtain an API key, first thing.
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
The given URL can be used for this:
https://newsdata.io/api/1/latest?apikey=YOUR_API_KEY
b. Request Method
For retrieving data, use the HTTP GET method.
GET https://newsdata.io/api/1/latest?apikey=YOUR_API_KEY
c. Add Query
You need to add a query to your request.
https://newsdata.io/api/1/latest?apikey=YOUR_API_KEY&q=pizza
NOTE: You can use multiple parameter like q, qInTitle, qInMeta, timeframe, etc to fetch the required data.
Request Parameter of Latest News Endpoints
1. id
Search for news articles using its unique “article_id” string. You can include up to 50 such article id strings in a single query or as per your specified limit.
For better understanding, below are some examples.
- If you set ‘id=668de67f2c32ce652104e7c4a5c9b517‘, it will fetch you article with the given unique article id.
https://newsdata.io/api/1/latest?apikey=YOUR_API_KEY&id=668de67f2c32ce652104e7c4a5c9b517
- If you set ‘id=668de67f2c32ce652104e7c4a5c9b517,8c2cc0fdb87a3382876dca3448eb4cbc,
ad77254cb843184f371908e1b984e517‘,
it will fetch you articles with specific article id’s only.
https://newsdata.io/api/1/latest?apikey=YOUR_API_KEY&id=668de67f2c32ce652104e7c4a5c9b517,8c2cc0fdb87a3382876dca3448eb4cbc,ad77254cb843184f371908e1b984e517
2. q
Search news articles for specific keywords present anywhere in the entire article.
For example, q=movies will show all the relevant articles that contain the keyword movies.
https://newsdata.io/api/1/latest?apikey=YOUR_API_KEY&q=movies
3. qInTitle
Search for specific keywords or phrases present in news titles among the fetched news articles. For example, qInTitle=football will show all the relevant articles that contain football in the news title.
https://newsdata.io/api/1/latest?apikey=YOUR_API_KEY&qInTitle=football
4. qInMeta
Search the news articles from the URL, meta description, and title by using this parameter.
https://newsdata.io/api/1/latest?apikey=YOUR_API_KEY&qInMeta=money
Click here to learn more about the q, qInTitle, and qInMeta parameters.
5. Timeframe
You can search the articles by using specific timeframes.
- The timeframe can be set between the 1-48 hour limit.
- The timeframe can also be set in the minutes range which is 1-2880 minutes.
Note: You can only use one parameter at a time.
- For example, if we set ‘timeframe=2’, it will show the articles from the past 2 hours only.
https://newsdata.io/api/1/latest?apikey=YOUR_API_KEY&q=food&timeframe=2
- For example, if we set ‘timeframe=104m’, it will show the articles from the past 104 minutes only.
https://newsdata.io/api/1/latest?apikey=YOUR_API_KEY&q=money&timeframe=104m
6. Country
Search the news articles from a specific country.
For example, ‘country=us’, where us means the United States.
The given request will fetch the articles related to ‘query=elon musk’ from the United States.
https://newsdata.io/api/1/latest?apikey=YOUR_API_KEY&q=elon musk&country=us
NOTE: You can add up to five countries in a single query. Check the codes for all the countries here.
7. Category
Search the news articles for a specific category.
For example, ‘category=politics’, top there is a total of 12 categories option available from which users can filter.
The given request will fetch the articles containing the keyword ‘modi’ and are related to the politics category.
https://newsdata.io/api/1/latest?apikey=YOUR_API_KEY&q=modi&category=politics
NOTE: You can add up to five categories in a single query.
8. Exclude Category
Exclude Categories to search for news articles.
For example, ‘excludecategory=politics’, this request will fetch all news articles from all other categories except politics.
The given request will fetch all the news articles containing the keyword ‘Modi’ from all the categories except politics.
https://newsdata.io/api/1/latest?apikey=YOUR_API_KEY&q=modi&excludecategory=politics
NOTE: You can add up to five categories in a single query.
NOTE: You can either include the ‘category’ or ‘excludecategory’ parameter in your query. You can’t use both parameters simultaneously.
9. Language
Search the news articles for a specific language.
For example, ‘language=en’, where en means English.
https://newsdata.io/api/1/latest?apikey=YOUR_API_KEY&q=ronaldo&language=en
The given request will fetch only those articles that are in English.
NOTE: You can add up to five languages in a single query.
10. Tags
This parameter helps search the news articles for specific AI-classified tags. This parameter allows you to search for articles beyond the keywords and seek AI’s help to enhance the data extraction.
Some of the ai_tags are ‘Banking and Finance’, ‘Diseases’, ‘Economy’, ‘Cricket’, etc. You can add up to 5 ai-tags in a single query. Check the codes for all ai_tags here. For example, tag=food, tourism.
https://newsdata.io/api/1/latest?apikey=pub_YOUR_API_KEY&tag=food,tourism
This query will fetch only those articles which have the ‘food’ and ‘tourism’ tags.
11. Sentiment
Search the news articles based on the sentiment of the news article. The sentiments are divided into three categories namely, ‘positive’, ‘neutral’, and ‘negative’ sentiment. This parameter screens the articles individually and analyses the tone and opinion expressed in the articles.This parameter helps enhance the user-experience and narrow done the data being extracted.
For example, sentiment=positive.
https://newsdata.io/api/1/latest?apikey=pub_YOU API KEY&q=ronaldo&sentiment=positive
This query will fetch those articles about Ronaldo that showcase positive sentiment only.
12. Region
This parameter helps search for the news articles from a specific region. This further helps narrow done the data and extract only the relevant data. The region could be a city, district, county, state, country, or continent. You can add up to 5 regions in a single query. For example, region=new york-united states of america
https://newsdata.io/api/1/latest?apikey=YOUR_API_KEY&q=crypto®ion=new york-united states of america
This query will fetch articles from the New York City of the United States of America only.
To learn more about this parameter, click here.
13. Domain
Search the news articles of specific news domains, such as the BBC or the New York Times.
For example, ‘domain=bbc.com’
NOTE: In case, you inserted wrong domain name the request will fail and you will see suggestions for domain you might be searching for.
The given request would fetch the articles that contain the keyword ‘Money’, which is from the bbc domain only.
https://newsdata.io/api/1/latest?apikey=YOUR_API_KEY&q=money&domain=bbc
NOTE: You can add up to 5 domains in a single query.
14. Domainurl
Allows users to extract articles from news domains.
For example, domainurl=bbc.com
The given request would fetch the articles that contain the keyword ‘games’ from the bbc domain only.
https://newsdata.io/api/1/latest?apikey=YOUR_API_KEY&q=games&domainurl=bbc.com
NOTE: You can add up to 5 domain URLs.
NOTE: If you enter the wrong domainurl, the system will show error and will suggest you the correct domainurl(s). You can then choose from the correct domainurl(s) and continue data fetching.
15. Exclude Domain
You can exclude the domains you don’t want articles from, using this parameter.
For example, ‘excludedomain=bbc.com’
The given request would fetch the articles that contain the keyword ‘games’, excluding the bbc domain.
https://newsdata.io/api/1/latest?apikey=YOUR_API_KEY&q=games&excludedomain=bbc.com
To clarify this request further, here is another example:
https://newsdata.io/api/1/latest?apikey=YOUR_API_KEY&q=ronaldo&excludedomain=nytimes.com
This will exclude all The New York Times news domain articles.
16. Excludefield
You can exclude the response object field you don’t want to be fetched regarding news articles, using this parameter.
For example, ‘excludefield=pubdate’
The given request would fetch the articles that doesn’t contain the ‘Publish Date’ field of response objects.
https://newsdata.io/api/1/latest?apikey=YOUR_API_KEY&q=games&excludefield=pubdate
To clarify this parameter further, here is another example:
https://newsdata.io/api/1/latest?apikey=YOUR_API_KEY&q=ronaldo&excludefield=imageurl
This will exclude the Image URL field of response objects from the articles fetched.
17. Domain Priority
This allows the users to extract news articles based on the domain authority of news sources.
There are three priority levels:
- Top: Fetches news articles from the top 10% of the news domains. The request parameter is ‘prioritydomain=top’.
https://newsdata.io/api/1/latest?apikey=pub_YOUR_API_KEY&q=global warming&prioritydomain=top
- Medium: Fetches news articles from the top 30% of the news domains. The request parameter is ‘prioritydomain=medium’.
https://newsdata.io/api/1/latest?apikey=pub_YOUR_API_KEY&q=modi&prioritydomain=medium
- Low: Fetches news articles from the top 50% of the news domains. The request parameter is ‘prioritydomain=low’.
https://newsdata.io/api/1/latest?apikey=pub_YOUR_API_KEY&q=modi&prioritydomain=low
18. Timezone
You can search the articles based on specific time zones.
The request parameter for the time zone would be ‘timezone=Asia/Dubai’.
https://newsdata.io/api/1/latest?apikey=YOUR_API_KEY&q=ronaldo&timezone=Asia/Dubai
19. Full Content
You can request a full-content article or without a full-content article using this parameter.
The request parameter would be ‘full_content=1’ for full content and ‘full_content=0’ for content that doesn’t contain full-width content.
- For full content
https://newsdata.io/api/1/latest?apikey=YOUR_API_KEY&q=global warming&full_content=1
- Without full content
https://newsdata.io/api/1/latest?apikey=YOUR_API_KEY&q=global warming&full _content=0
20. Image
This parameter allows you to search for articles with or without featured images.
The request parameter would be ‘image=1’ for articles with featured images and ‘image=0’ without featured images.
- For articles with featured images
https://newsdata.io/api/1/latest?apikey=YOUR_API_KEY&q=global warming&image=1
- For articles without featured images
https://newsdata.io/api/1/latest?apikey=YOUR_API_KEY&q=global warming&image=0
21. Video
This parameter would help users retrieve articles containing videos.
The request parameter would be ‘video=1’ for articles with video and ‘video=0’ for those without video.
- For articles with video
https://newsdata.io/api/1/latest?apikey=YOUR_API_KEY&q=modi&video=1
- For articles without video
https://newsdata.io/api/1/latest?apikey=YOUR_API_KEY&q=modi&video=0
22. Removeduplicate
This parameter would help users to remove duplicate articles.The request parameter to remove duplicate articles would be ‘removeduplicate=1‘
https://newsdata.io/api/1/latest?apikey=YOUR_API_KEY&q=modi&removeduplicate=1
NOTE:The article with ‘removeduplicate=1’ parameter doesn’t necessarily mean that the article is a duplicate article, this parameter is based on Newsdata.io’s internal algorithm.
23. Size
This allows users to customize the number of articles that can be fetched per API request.
For free users, the maximum limit is 10, while it is up to 50 for paid users.
The parameter for this request would be size=25.
- This request will fetch 30 articles/requests but only for paid users because their max limit is up to 50.
https://newsdata.io/api/1/latest?apikey=YOUR_API_KEY&q=money&size=30
- This request will fetch 10 articles/requests for free and paid users, respectively.
https://newsdata.io/api/1/latest?apikey=YOUR_API_KEY&q=money&size=10
NOTE: If free users try to fetch more than the limit, then the request will fail and an error will be displayed.
24. Page
This parameter allows the user to navigate to the next page. While fetching the data you will see a ‘nextPage’ string at the bottom of the screen. You can insert this in your query in order to navigate to the next page manually.
For Example:
https://newsdata.io/api/1/latest?apikey=YOUR_API_KEY&q=YOUR_QUERY&page=XXXPPPXXXXXXXXXX
This parameter will take you to the nextPage with a set of new articles.
To learn more about this parameter, click here.
Hello, Curious Minds!
Welcome to my corner of the digital world, a space brimming with words and woven with ideas. Fresh out of the rigorous trenches of an Economics honors degree at the esteemed University of Delhi, I know a thing or two about crunching numbers and dissecting trends. But beyond the world of graphs and equations, lies my love for reading and writing. Admittedly, I’m a newbie in the content writing scene, still tasting the ink of fresh beginnings. I believe every corner of life holds a story waiting to be told, and I’m eager to be your storyteller. So, strap yourselves in, dear readers, and let’s dive into the captivating world of words together!
P.S. Feel free to drop a comment or reach out – I’m always up for a good conversation!