News API v3 quickstart guide
This guide will help you make your first API call to NewsCatcher News API v3 and start retrieving news data in just a few minutes.
Before you start
Before you begin, make sure you meet these prerequisites:
- An API key for NewsCatcher News API v3 (obtained from your account manager)
- Python 3.6+ installed on your system
- The
requests
library for Python
Get started
Step 1 - Set up your environment
First, make sure you have Python and the requests library installed. You can install requests using pip:
Step 2 - Create your first script
Create a new file named newscatcher_quickstart.py
and add the following code:
Remember to replace YOUR_API_KEY_HERE
with your actual API key.
Step 3 - Run the script and review the results
Run the script from your terminal:
You should see a JSON response similar to this (shortened for readability):
This response shows you the rich data available for each article, including detailed metadata such as title, author, publication date, source information, and content.
Step 4 - Modify the query for more specific results
Now that you’ve seen the basic API response, let’s modify our script to filter the results and include some advanced features. Update your script as follows:
This modified script:
- Searches for “electric vehicles”.
- Limits results to articles from the United States and Great Britain.
- Retrieves articles from the last 7 days.
- Returns ten articles per page.
- Includes NLP data in the results.
- Displays the title, publish date, content sentiment score, and theme for each article.
Run the script again to see the filtered results with NLP data.
What’s next
Now that you’ve made your first calls to the NewsCatcher News API v3 and explored some of its features, here are some next steps to enhance your usage:
- Explore other parameters like
predefined_sources
,sort_by
,iptc_tags
, oriab_tags
to refine your searches. - Check out our API Reference to learn about all available endpoints and parameters.
- Learn how to Implement pagination to handle large datasets.
- Dive deeper into the NLP features to extract insights from the news articles.
If you have any questions or need assistance, don’t hesitate to contact our support team. Happy news hunting!