Retrieve all articles for a query that exceeds the 10,000 article limit using time-chunking across Python, TypeScript, and Java
News API returns up to 10,000 articles per query. For broad queries this limit
is hit constantly — a search for “artificial intelligence” in English returns
10,000 results even when hundreds of thousands of matching articles exist.This guide walks through the full retrieval workflow in three steps: measure
your dataset volume, choose the right chunk size, then fetch everything. All
three steps include code examples for Python, TypeScript, and Java.
Before writing any retrieval logic, use
/aggregation_count
to understand how many articles your query actually matches and how they’re
distributed over time. This tells you which chunk size to use and whether your
query needs narrowing.
Python SDK provides get_all_articles and get_all_headlines — methods that
automate the workflow. They split your date range into chunks, paginate each
chunk, deduplicate results, and return a combined list. You can still measure
volume with /aggregation_count to choose a proper time_chunk_size, but you
don’t need to write the iteration logic.
Time-chunking divides your date range into smaller intervals, makes a separate
API call for each period, and combines the results. Each interval can return up
to 10,000 articles.For example, with time_chunk_size="1d" over 5 days, the method makes 5 API
calls — one per day — with automatic pagination, retrieving up to 50,000
articles total.
Retrieves all articles matching a search query over a date range. Accepts all
standard /search endpoint parameters via **kwargs — lang, countries,
sort_by, include_nlp_data, and so on.
AsyncNewscatcherApi only. Number of concurrent page requests within each
time chunk.
Both methods accept all other endpoint parameters via **kwargs and pass them
to the API. For example, you can filter by language, sort by relevance, or
include NLP data in results from either method — just as you would with direct
API calls to /search or /latest_headlines.
For async Python, reduce concurrency. For manual iteration, add delays
between window requests. If limits are hit consistently, consider narrowing
your query to reduce overall volume.
Timeout errors (408)
Your chunk size is still too large. Step down: "1d" → "6h" → "1h".
For long historical ranges, see
Working with historical data.
Memory errors
Reduce max_articles (Python SDK), or write results to disk per window
rather than accumulating everything in memory.
Result counts vary between runs
News sources publish continuously. Counts for recent ranges differ between
runs as new articles are indexed. Use a fixed to date for reproducible
datasets.
Measure before you iterate. One /aggregation_count call tells you the
exact volume and distribution — it takes seconds and prevents wasted API
calls on a wrong chunk size.
Set a fixed to date for reproducible jobs. Open-ended to="now" means
results change between runs.
Use show_progress=True during development (Python SDK). It surfaces
slow chunks and stalls early.
Lower max_articles if you don’t need everything (Python SDK). The
default is 100,000 — set it to your actual target to avoid unnecessary calls.
Store results incrementally for large jobs. Write to disk per window
rather than accumulating everything in memory.