npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

pagination-harvest

v2.0.2

Published

A blazing fast, parallelized, and small data harvester for paginated APIs. Supports Axios and custom fetchers, progress callbacks, and automatic retry.

Readme

pagination-harvest

A blazing fast, parallelized data harvester for paginated APIs.
pagination-harvest helps you gather all data from APIs that return paginated results, with automatic parallel fetching, retries, and progress callbacks.
It supports any custom fetcher (Axios, fetch API, etc.) making it highly flexible for any backend, frontend, or custom API architecture.


🚀 Features

  • Fetch all pages from paginated APIs automatically
  • Ultra-fast: fetches multiple pages in parallel
  • Retry mechanism for failed pages
  • Progress callback for UI feedback
  • Works out of the box with any custom fetch logic
  • Written in TypeScript, fully typed

📦 Installation

npm install pagination-harvest
# or
yarn add pagination-harvest

🛠️ Usage Example

Custom Fetch Function

You can use your own fetch logic (axios, fetch, any library):

import paginationHarvest from "pagination-harvest";

const fetchPageFn = async (page: number, limit: number) => {
  const res = await fetch("/api/items", {
    method: "GET",
    headers: { Authorization: "Bearer your-jwt-token" },
    params: { page, limit }
  });

  const json = await res.json();

  return {
    data: json.items,           // Array of items from this page
    totalPages: json.totalPages // Total number of pages (optional, but useful)
  };
};

const { data, failedPages } = await paginationHarvest({
  fetchPageFn,
  limit: 100,
  maxParallel: 8,
  maxRetries: 3,
  onProgress: (fetched, total) => {
    console.log(`📥 Downloaded ${fetched} / ${total} pages`);
  },
  startPage: 1
});

console.log("All data collected:", data);
console.log("Failed pages (after retries):", failedPages);

🔖 Props Reference

| Prop | Type | Required | Default | Description | |------------------|-----------------------------|----------|-----------|---------------------------------------------------------------------------------------------| | fetchPageFn | (page, limit) => Promise<{ data: T[]; totalPages?: number }> | Yes | - | Custom page fetcher. | | startPage | number | No | 1 | The starting page number. | | limit | number | No | 500 | Number of items per page. | | maxParallel | number | No | 10 | Maximum number of concurrent page fetches. | | maxRetries | number | No | 2 | Number of retry attempts for failed pages. | | onProgress | (fetchedPages, totalPages) => void | No | - | Callback invoked every time a page is fetched. |

⚡️ Response

The function resolves to:

type PaginationHarvestResult<T> = {
  data: T[];         // All data items from all pages
  failedPages: number[]; // Array of pages that failed to fetch after retries
}

Let’s harvest data—fast, smart, and yours. 🌱


🧑‍💻 License

MIT