
In this article, we’ll dive into the details of the “Python Client” integration guide.
Python Client
With the “Client Python” section of the NewsData.io documentation, you can effortlessly integrate the API into your Python applications, whether you’re building news aggregators, data analysis tools, or research platforms.
Initial Steps of Integration News API in Python
Obtain API Key
The first step is obtaining your unique API key by registering for an account. This serves as the authentication token for your requests.
Install newsdataapi
Start by installing the “newsdataapi” library using the given pip command:
pip install newsdataapi
Import the ‘NewsDataApiClient’ package into your program.
from newsdataapi import NewsDataApiClient
Now, NewsData.io offers 4 endpoints, i.e., crypto_api, news_api, latest_api, and archive_api. Let’s understand the different request parameters of each endpoint.
1. ‘Latest’ News Endpoint
‘Latest‘ News endpoint allows users to get the top live breaking news of the past 48 hours from all over the world. To fetch the Latest news, follow the steps mentioned below.
After the initial integration, the latest news parameter would be:
- ‘For API key authorization, initialize the client with your API key
api = NewsDataApiClient(apikey=’YOUR_API_KEY’)
- Data can now be fetched:
response = api.latest_api()<br />
print(response)
The ‘latest’ news endpoint accepts queries and other supported parameters in brackets (). Enter the information you want to retrieve data about within these brackets.
Let’s understand with the help of an example.
If you want to fetch data on Pizza, then q=pizza. The request parameter will be:
response = api.latest_api(q=pizza)
api = NewsDataApiClient(apikey='YOUR_API_KEY')
response = api.latest_api(q='pizza')
print(response)This will fetch all the articles related to pizza from the past 48 hours. And to navigate to the next page, you need to use the nextPage parameter.
You can use the scroll parameter to fetch less amount of data. To scroll through all the latest news extracted by the news API:
api = NewsDataApiClient(apikey='YOUR_API_KEY')
response = api.latest_api(q='pizza',scroll=True,max_result=1000)
print(response)The ‘max_result’ parameter is used with the scroll parameter to set the limit of results according to your requirements.
api = NewsDataApiClient(apikey='YOUR_API_KEY')
responses = api.latest_api(q='pizza',paginate=True,max_pages=10)
for response in responses:
print(response)This parameter will fetch you 1000 articles from the available articles.
If you want to fetch a large amount of data, you can use the paginate parameter. It provides you with results—pages with large amounts of data.
response = api.latest_api(q=pizza,paginate=true)
print(response)
The “Max_pages” parameter is used with the paginate parameter to limit the number of page results according to the requirement.
response = api.latest_api(q=pizza,paginate=true,max_pages=5)
print(response)
2. ‘Crypto’ News Endpoint
‘Crypto‘ news endpoint allows users to fetch all the news articles related to cryptocurrency.
The query here is ‘Bitcoin‘ such that the request parameter for crypto news API is:
api = NewsDataApiClient(apikey='YOUR_API_KEY')
response = api.crypto_api(q='bitcoin')
print(response)The ‘crypto‘ endpoint accepts queries and other supported parameters in brackets (). Enter the information you want to retrieve data about within these brackets.
The ‘scroll=True’ and ‘max_result’ parameters can also be used to help fetch data.
3. News ‘Archive’ Endpoint
News ‘Archive‘ endpoint allows paid users to access historical news for up to 2 to 5 years, as per the subscription plans. Access to older news can be further provided by contacting the website.
The query here is assumed to be pizza, such that the request parameter is:
api = NewsDataApiClient(apikey='YOUR_API_KEY')
response = api.archive_api(q='pizza',from_date='2021-01-01',to_date='2021-06-06')
print(response)
The given query will fetch you all the articles on pizza from January 1st, 2021, to June 6th,2021.
api = NewsDataApiClient(apikey='YOUR_API_KEY')
response = api.archive_api(q='pizza',from_date='2025-01-01',to_date='2025-06-15')
print(response)The ‘archive‘ endpoint accepts queries and other supported parameters in brackets (). Enter the information you want to retrieve data about within these brackets.
The ‘scroll=True’ and ‘max_result’ parameters can also be used to help fetch data.
You can add categories, languages, and countries as well. Check out the documentation to learn more about it.
4. News ‘Sources’ Endpoint
To get a list of 100 random sources of Newsdata.io News API use:
api = NewsDataApiClient(apikey='YOUR_API_KEY')
response = api.sources_api(language='en')
print(response)The given request will fetch a list of 100 random news sources.
5. Market News Endpoint
The Market News endpoint provides access to the latest and most relevant financial news, stock market news, and business-related news.
The query here is ‘AAPL’, such that the request parameter for the Market News API is:
api = NewsDataApiClient(apikey='YOUR_API_KEY')
response = api.market_api(q='AAPL')
print(response)6. News Count
The Count Endpoint allows you to get the exact number of news articles on a daily and hourly basis available in the NewsData.io database that match your query filters, without fetching the actual articles.
The example for the count news endpoint will be such as:
api = NewsDataApiClient(apikey='YOUR_API_KEY')
response = api.count_api(q='pizza',from_date='2025-01-01',to_date='2025-06-15')
print(response)Example code for Crypto Count News Endpoint will be such as:
api = NewsDataApiClient(apikey='YOUR_API_KEY')
response = api.crypto_count_api(q='bitcoin',from_date='2025-06-01',to_date='2025-11-15')
print(response)The example for the Market Count Endpoint will be such as:
api = NewsDataApiClient(apikey='YOUR_API_KEY')
response = api.market_count_api(q='AAPL',from_date='2025-06-01',to_date='2025-11-15')
print(response)Note: The parameters discussed above can be used for all the news endpoints except news sources in the Python client.
Frequently Asked Questions
Q1. How to access news API in Python?
To access news API in Python first you need to get an API key from your provider. Once done, you need to send HTTP requests to your API endpoints with the required parameters and headers to get the news data programmatically. For detailed information visit the Python client library.
Q2. Can I filter news articles using the Python client?
Yes, you can filter news articles using the Python client. You can filter the articles by either filtering using a keyword or by filtering using tags.
Q3. Does the Newsdata.io News API support real-time news updates?
Yes, Newsdata.io News API provide real-time news updates. This means you can retrieve news articles as soon as they are published by various news sources.
Raghav Sharma is a content writer and media researcher at Newsdata.io, specializing in news industry analysis, media literacy, and the evolving landscape of digital journalism. With a background in English Literature and Journalism, along with a focus on fact-based reporting standards, Raghav covers topics including news API technology, editorial bias evaluation, and responsible information consumption. Raghav’s work has covered media trends across categories, including healthcare news, international journalism, and API-driven publishing. You can connect with him on LinkedIn or explore more of his writing on the Newsdata.io blog.

