Documentation
Guides and reference materials to help you get started, integrate, optimize and troubleshoot your use of the Newsdata.io Platform.
Introduction
This is the documentation page intended to demonstrate various API endpoints that you can use and the parameters that are available when calling them. Different API endpoints are grouped by topic in the left side menu. For most endpoints, you can also check multiple code examples that demonstrate its use using your preferred programming language.
Authentication
The NewsData.io API uses API keys to authenticate requests. Your API keys carry many privileges, so be sure to keep them secure! Do not share your secret API keys in publicly accessible areas such as GitHub, client-side code, and so forth.
To obtain an API key you have to create an account. You get a free API key while you are in development. When making REST API requests, your API key has to be provided as a parameter in the URL (e.g. apikey=YOUR_API_KEY).
HTTP Response Code
These error codes are produced on their given conditions
Get Latest News
The latest news endpoint provides access to the latest and breaking news for a country, for a specific category in a country, or for a single or multiple domains. The news articles are sorted by the publish date.
Retrieving the latest news allows you to build experience such as showcasing the latest news, breaking news tickers and analyzing News to better understand their content.
Request Parameters
apikey
required
|
string
Your Newsdata.io API Key. Alternatively you can provide this via the
X-ACCESS-KEY HTTP header.
|
country |
string
A comma separated string of 2-letter ISO 3166-1 countries (maximum 5) to restrict the search to.
API URL: https://newsdata.io/api/1/news?apikey=YOUR_API_KEY&country=au,ca
|
category |
string
A comma separated string of categories (maximum 5) to restrict the search to.
API URL: https://newsdata.io/api/1/news?apikey=YOUR_API_KEY&category=sports,health
|
language |
string
A comma separated string of languages (maximum 5) to restrict the search to.
API URL: https://newsdata.io/api/1/news?apikey=YOUR_API_KEY&language=fr,en
|
domain |
string
A comma separated string of domains (maximum 5) to restrict the search to. Use the
/domains endpoint to find top sources id.
API URL: https://newsdata.io/api/1/news?apikey=YOUR_API_KEY&domain=ctvnews_london
|
q |
string
Keywords or phrases to search for in the news title and content. The value must be URL-encoded
Advance search options:
|
qInTitle |
string
Keywords or phrases to search for in the news title only.
Please note: This parameter can't be used with q parameter in the same query.
|
page |
string
Use this to page through the results if the total results found is greater than the page size.
|
Sample Response
Response Object
status |
string
Status shows the status of your request. If the request was successful then it shows
success , in case of error it shows error . In the case of error a code and message property will be displayed.
|
||||||||||||||||||||||||||
totalResults |
int
The total number of results available for your request.
|
||||||||||||||||||||||||||
results |
array
The results of the request
|
||||||||||||||||||||||||||
nextPage |
string
|
Sample Response
Sample Response
News Archive
The news archive endpoint provides access to the old news data for a country, for a specific category in a country, or for a single or multiple domains.
Retrieving a piece of old news allows you to get the past news data for research and analysis purposes.
Request Parameters
apikey
required
|
string
Your Newsdata.io API Key. Alternatively you can provide this via the
X-ACCESS-KEY HTTP header.
|
country |
string
A comma separated string of 2-letter ISO 3166-1 countries (maximum 5) to restrict the search to.
API URL: https://newsdata.io/api/1/archive?apikey=YOUR_API_KEY&country=au,jp
|
category |
string
A comma separated string of categories (maximum 5) to restrict the search to.
API URL: https://newsdata.io/api/1/archive?apikey=YOUR_API_KEY&category=sports,top
|
language |
string
A comma separated string of languages (maximum 5) to restrict the search to.
API URL: https://newsdata.io/api/1/archive?apikey=YOUR_API_KEY&language=fr,es
|
domain |
string
A comma separated string of domains (maximum 5) to restrict the search to. Use the
/domains endpoint to find top sources id.
API URL: https://newsdata.io/api/1/archive?apikey=YOUR_API_KEY&domain=ctvnews_london
|
from_date |
string
A date and optional time for the oldest article allowed. This should be in ISO 8601 format
(e.g. 2021-04-18 or 2021-04-18T04:04:34)
API URL: https://newsdata.io/api/1/archive?apikey=YOUR_API_KEY&from_date=2021-04-18
|
to_date |
string
A date and optional time for the newest article allowed. This should be in ISO 8601 format
(e.g. 2021-04-18 or 2021-04-18T04:04:34)
API URL: https://newsdata.io/api/1/archive?apikey=YOUR_API_KEY&to_date=2021-04-18
|
q |
string
Keywords or phrases to search for in the news title and content. The value must be URL-encoded
Advance search options:
|
qInTitle |
string
Keywords or phrases to search for in the news title only.
Please note: This parameter can't be used with q parameter in the same query.
|
page |
string
Use this to page through the results if the total results found is greater than the page size.
|
Sample Response
Response Object
status |
string
Status shows the status of your request. If the request was successful then it shows
success , in case of error it shows error . In the case of error a code and message property will be displayed.
|
||||||||||||||||||||||||||
totalResults |
int
The total number of results available for your request.
|
||||||||||||||||||||||||||
results |
array
The results of the request
|
||||||||||||||||||||||||||
nextPage |
string
page parameter value for next request.
|
Sample Response
Sample Response
News Sources
News sources endpoint provides access to the subsets of news publishers that the latest news is available from.
It's mainly a convenience endpoint that you can use to keep track of the publishers available on the API, and you can pipe it straight through to your users
Request Parameters
apikey
required
|
string
Your Newsdata.io API Key. Alternatively you can provide this via the
X-ACCESS-KEY HTTP header.
|
country |
string
Find sources that display news in a specific country.
API URL: https://newsdata.io/api/1/sources?apikey=YOUR_API_KEY&country=jp
|
category |
string
Find sources that display news of this category.
API URL: https://newsdata.io/api/1/sources?apikey=YOUR_API_KEY&category=sports
|
language |
string
Find sources that display news in a specific language.
API URL: https://newsdata.io/api/1/sources?apikey=YOUR_API_KEY&language=en
|
Sample Response
Response Object
status |
string
Status shows the status of your request. If the request was successful then it shows
success , in case of error it shows error . In the case of error a code and message property will be displayed.
|
||||||||||||
results |
array
The results of the request
|
Sample Response
Sample Response
Get Crypto News
Search and Monitor Worldwide Cryptocurrency-related news and blog data from the most reliable News and Blog Websites
Retrieving the latest news allows you to build experience such as showcasing the latest news, breaking news tickers and analyzing News to better understand their content.
Request Parameters
apikey
required
|
string
Your Newsdata.io API Key. Alternatively you can provide this via the
X-ACCESS-KEY HTTP header.
|
country |
string
A comma separated string of 2-letter ISO 3166-1 countries (maximum 5) to restrict the search to.
API URL: https://newsdata.io/api/1/crypto?apikey=YOUR_API_KEY&country=au,ca
|
language |
string
A comma separated string of languages (maximum 5) to restrict the search to.
API URL: https://newsdata.io/api/1/crypto?apikey=YOUR_API_KEY&language=fr,en
|
domain |
string
A comma separated string of domains (maximum 5) to restrict the search to. Use the
/domains endpoint to find top sources id.
API URL: https://newsdata.io/api/1/crypto?apikey=YOUR_API_KEY&domain=coinspeaker
|
q |
string
Keywords or phrases to search for in the news title and content. The value must be URL-encoded
Advance search options:
|
qInTitle |
string
Keywords or phrases to search for in the news title only.
Please note: This parameter can't be used with q parameter in the same query.
|
page |
string
Use this to page through the results if the total results found is greater than the page size.
|
Sample Response
Response Object
status |
string
Status shows the status of your request. If the request was successful then it shows
success , in case of error it shows error . In the case of error a code and message property will be displayed.
|
||||||||||||||||||||||||||
totalResults |
int
The total number of results available for your request.
|
||||||||||||||||||||||||||
results |
array
The results of the request
|
||||||||||||||||||||||||||
nextPage |
string
|
Sample Response
Sample Response
Client Libraries
Use a client library (SDK) to quickly and easily get started with Newsdata.io API without having to make HTTP requests directly.
We have libraries for the following languages:
Python
Use the Newsdata.io Python client library to integrate Newsdata.io API into your Python application without having to make HTTP requests directly.
Source: Newsdata.io Python Client
Installation:
Usage:
from newsdataapi import NewsDataApiClient
# API key authorization, Initialize the client with your API key
api = NewsDataApiClient(apikey="YOUR_API_KEY")
# You can pass empty or with request parameters {ex. (country = "us")}
response = api.news_api( q= "ronaldo" , country = "us")
PHP
Use the Newsdata.io PHP client library to integrate Newsdata API into your PHP application without having to make HTTP requests directly.
Source: Newsdata.io PHP bindings
Installation:
Usage:
require_once '../autoload.php';
use NewsdataIO\NewsdataApi;
$newsdataApiObj = new NewsdataApi("YOUR_API_KEY");
// Pass your desired strings in an array with unique key
$data = array("q" => "ronaldo", "country" => "ie");
$response = $newsdataApiObj->get_latest_news($data);
?>