miniget is a lightweight HTTP(S) GET request library designed for both Node.js and browser environments, emphasizing minimal dependencies and a small footprint. It provides core functionalities like automatic redirects (up to 10 by default), request retries for 5xx or connection errors, and reconnects for interrupted downloads, allowing streams to resume. The current stable version is `4.2.3`, with releases typically addressing bug fixes and minor features rather than following a strict semantic versioning cadence between major versions. Key differentiators include its zero-dependency nature, support for streaming responses via a readable stream, and methods for concatenating responses into a single text body. It also exposes a configurable `defaultOptions` object for global settings and ships with TypeScript type definitions, making it well-suited for modern TypeScript projects.
npm install minigetVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates both promise-based text retrieval and streaming a response to a file using `miniget`, including error handling and event listeners for redirects and responses. It also shows how to configure global default options.
Replace `stream.on('close', ...)` listeners with `stream.on('end', ...)` for the miniget stream or `fileStream.on('finish', ...)` if piping to a writable stream.Update all calls from `stream.abort()` to `stream.destroy()` to use the current API.
Upgrade to `miniget` v4.2.1 or a newer version to resolve webpack compatibility issues.
Ensure your Node.js runtime environment is version 12 or higher to guarantee compatibility and stability.
If working in an ESM environment, use `import miniget from 'miniget';` instead of `const miniget = require('miniget');`.For ESM, use `import miniget from 'miniget';`. For CommonJS, use `const miniget = require('miniget');`.Ensure the URL parameter is a correctly formatted string (e.g., `https://example.com/resource`) or a valid `URL` object instance.
Remove the `stream.on('close', ...)` listener from your code. If you need to detect stream completion, use `stream.on('end', ...)` or monitor the completion of downstream writable streams (e.g., `fileStream.on('finish', ...)`) if you are piping the data.No dependency data recorded yet.