How to check sources coverage
Learn how to verify the news sources covered by News API v3
Overview
Understanding the sources covered by News API v3 is crucial for ensuring the
comprehensiveness and reliability of your news data analysis. This guide will
walk you through the process of checking source coverage using the /source
endpoint, including how to handle large numbers of sources efficiently.
Before you start
Before you begin, ensure you have:
- An active API key for NewsCatcher News API v3
- Basic knowledge of making API requests
- Python or another tool for making HTTP requests (e.g., cURL, Postman, or a programming language with HTTP capabilities)
Steps
Understand key parameters
To make a valid request to the /sources
endpoint, use at least one of the
following key parameters:
lang
: The language(s) of the sources.countries
: The countries where the news publishers are located.predefined_sources
: Predefined top sources per country.source_name
: Text to search within source names. You can specify any word, term, phrase, or outlet name.source_url
: The domain(s) of the news publication to search for. When specifying this parameter, you can only useinclude_additional_info
as an extra parameter.
To refine your search and obtain addional source info, you can use:
include_additional_info
: Set totrue
to get extra details about each source.from_rank
andto_rank
: Filter sources by their SEO rank.
For detailed descriptions and usage of all parameters, refer to the Sources reference documentation.
Construct a query and make an API request
Here’s a Python example demonstrating how to check for sources containing a specific word:
Analyze the response
The API response will include information about the requested source(s). Here’s an example response:
This response shows a list of sources that include “sport” in their names.
Search by source_name
does not perform an exact match and returns all
sources that contain the specified term anywhere in their names.
Check coverage for specific sources
To check coverage for specific sources, you can use the source_url
parameter
for precise filtering:
You can also combine multiple parameters to narrow down your search. For example, to find sports-related sources in English-speaking countries:
The response will include information for each covered source that matches your criteria.
Handling large numbers of sources
When dealing with a large number of sources, you may have them stored in a file
(e.g., CSV or JSON). Here’s an approach using asynchronous requests to check
which sources are covered by News API v3 and identify those that are not. This
implementation uses aiohttp
and asyncio
libraries for concurrent requests,
providing better performance and scalability.
The API key is stored in an environment variable for security purposes. Set
your NEWSCATCHER_API_KEY
in your environment before running the script.
For example, in a Unix-like terminal (Linux or macOS), you can set it like this:
On Windows Command Prompt, you can use:
This script does the following:
- Reads source URLs from a CSV file.
- Asynchronously checks the sources against the API in batches of 1000.
- Identifies which sources are not covered by the API.
- Writes the uncovered sources to a new CSV file.
To use this script:
- Save your list of source URLs in a CSV file named
source_urls.csv
. - Run the script. It will create a file named
uncovered_sources.csv
containing the URLs not covered by News API v3.
You can then send the uncovered_sources.csv
file to our support team. As News
API v3 is a flexible, corporate-level solution, we can manually add the sources
you need for your application.
This script assumes that your source URLs are in the first column of the input
CSV. Adjust the read_sources_from_csv
function if your file has a different
structure.
Best practices
Use the include_additional_info
parameter to get insights into source
reliability and output volume.
Use source_name
for a broader search and the source_url
for more precise
results.
For large numbers of sources, use the batching method described above to stay within API limits.
Remember that the API may limit the number of sources returned based on your subscription plan.
See also
Was this page helpful?