Registry / devops / rest-collection-stream

rest-collection-stream

JSON →
library0.0.1jsnpmunverified

A Node.js HTTP client that streams JSON content from REST collections and lists, with automatic pagination support for continuous streaming across multiple requests. Version 0.0.1 is an early release with limited maintenance. Unlike simple HTTP clients, it transparently handles common pagination patterns (Link headers, envelope properties like nextLink, @odata.nextLink, etc.) and extracts array data from response bodies. Requires the 'request' package (deprecated) as a dependency and works only in Node.js with JSON APIs.

npm install rest-collection-stream
INSTALL
IMPORT
SIG · REST-COLLECTION-ST
R
rest-collection-stream
devopsjavascriptv0.0.1
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default (function)
import restCollection from 'rest-collection-stream'
import { restCollection } from 'rest-collection-stream'
The module exports a single function as the default export; named import will result in 'undefined'.
CommonJS require
const restCollection = require('rest-collection-stream')
const { restCollection } = require('rest-collection-stream')
In CommonJS, destructuring will not work because the exported value is a function, not an object.
No TypeScript types
// @ts-ignore const restCollection = require('rest-collection-stream')
The package does not include TypeScript declarations; you must use a type assertion or declaration file.

Demonstrates basic usage: getting a stream from a REST collection and piping it to a file.

const restCollection = require('rest-collection-stream'); const fs = require('fs'); const stream = restCollection('https://jsonplaceholder.typicode.com/posts'); stream.pipe(fs.createWriteStream('posts.json')); stream.on('end', () => console.log('Done'));
Debug
Known issues
deprecatedPackage depends on 'request' which is deprecated. The 'request' package is no longer maintained and has known vulnerabilities.
fix
Migrate to a modern HTTP client like 'got', 'node-fetch', or 'axios'. This package may not be updated to do so.
affects: >=0.0.0
gotchaThe `data` option function signature uses `this.emit('data', item)` for custom streaming, but the stream context may not be reliable.
fix
Use the callback-style return pattern instead of relying on `this`: return an array of items from the `data` function.
affects: >=0.0.0
gotchaThe `json` option is always forced to true; non-JSON responses will cause parsing errors.
fix
Ensure the API returns valid JSON. If not, consider a different HTTP client.
affects: >=0.0.0
gotchaAutomatic pagination detection may fail for APIs with non-standard envelope structures, causing incomplete streaming.
fix
Provide a custom `next` function to handle your API's pagination logic.
affects: >=0.0.0
Errors
Common errors & fixes
TypeError: restCollection is not a function
Using named import instead of default import in ES modules.
fix
Use default import: `import restCollection from 'rest-collection-stream'` (not `import { restCollection }`).
request is not defined
The 'request' dependency is missing or not installed.
fix
Ensure 'request' is in your package.json: `npm install request`. Consider replacing request due to deprecation.
Error: Invalid JSON response
The API returned non-JSON (e.g., HTML, XML) but the module forces JSON parsing.
fix
Verify the API URL and that it returns JSON. For non-JSON APIs, use a different library.
Upgrade
Version history
0.0.1latest on npm
Audit
Dependencies
requestrequiredThe library wraps the 'request' HTTP client for making requests; 'request' is deprecated and no longer maintained.
Agent activity
8 hits · last 30 days
node
8
Resources
rest-collection-stream — npm install rest-collection-stream · libregistry