PAGINATION

Paginate search results

Search results are paged with page and page_size. Each response includes totalResults, page and pageSize, so you always know how far there is to go.

Parameters

Pagination parameters
ParameterTypeDefaultConstraints
pageinteger1minimum: 1, maximum: 10000
page_sizeinteger10minimum: 1, maximum: 100

Pages start at 1, and page × page_size can't exceed 10,000. Results are newest-first by default, so new articles arriving while you page can shift items between pages; pass a fixed to timestamp for a more stable snapshot.

Loop through pages

Stop when a page comes back short or you reach the reachable total. Each page is one request; use up to 100 articles per request to reduce call count.

async function* allArticles(query, pageSize = 50) {
  for (let page = 1; ; page++) {
    const url = new URL("https://apis.newssearchapi.com/v1/articles");
    url.search = new URLSearchParams({ ...query, page: String(page), page_size: String(pageSize) }).toString();
    const body = await (await fetch(url, { headers: { "X-Api-Key": process.env.NEWSSEARCHAPI_API_KEY } })).json();
    if (body.status !== "ok") throw new Error(`${body.code}: ${body.message}`);

    yield* body.articles;
    const reachable = Math.min(body.totalResults, 10_000);
    if (body.articles.length < pageSize || page * pageSize >= reachable) return;
  }
}

for await (const article of allArticles({ q: "climate", from: "2026-10-01" })) console.log(article.title);

The SDKs provide this as articles.iterate().

More than 10,000 results

totalResults can be larger than 10,000, but only the first 10,000 are reachable by paging. To export more, split the query into date windows with from and to (for example one day at a time) and page through each window.

Page size and credits

The global maximum is page_size=100. One credit is $0.01. Searches cost 0.1 credit, covering the first 10 returned articles; each additional article costs 0.01 credit. Each successful search costs its 0.1-credit base even with no results. A search also costs 0.2 credit per started day beyond 30 days. When dates are omitted, the default search window is 7 days; that is separate from the 30 days of history included in pricing. Article lookups cost 0.1 credit; errors are not charged.

Stuck or found a mistake?Email developer support

Esc to close · ↑↓ Tab to move through results