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 🙏

© 2025 – Pkg Stats / Ryan Hefner

reso.js

v0.2.1

Published

A robust, Typescript-first Node.js client designed for interacting with RESO Web API services, fully aligned with the current RESO Web API specification.

Readme

reso.js

reso.js is a robust, Typescript-first Node.js client designed for interacting with RESO Web API services.

It is fully compliant with the current RESO Web API specification and provides commonly used features out-of-the-box, including:

  • Automatic Pagination
  • Authentication
  • Built-in Rate Limiting

It includes features like custom request/response hooks, automatic authentication token refresh, and built-in rate limiting.

Table of Contents

Installation

Install with your preferred package manager:

pnpm add reso.js
# or
npm install reso.js
# or
yarn add reso.js

Compatibility

This library works with any RESO-compliant server following the RESO Web API spec. Additionally, it provides official support for:

Usage

Getting Started

reso.js supports both Bearer Token and Client Credentials authentication strategies. Refer to your feed's documentation for your the supported strategy and how to obtain credentials.

Bearer Token Authentication

This strategy is used when you have a long-lived, non-expiring token.

import { createFeed } from 'reso.js';

const feed = createFeed({
	http: {
		baseURL: 'http://my-reso-api.com',
	},
	auth: {
		type: 'token',
		credentials: {
			token: 'MY_TOKEN',
		},
	},
});

The bearer token provided must not expire.

Client Credentials Authentication

This strategy is required when the provider uses the OAuth 2.0 Client Credentials flow, it will autemtically refresh the token before it expires.

import { createFeed } from 'reso.js';

const feed = createFeed({
	http: {
		baseURL: 'http://my-reso-api.com',
	},
	auth: {
		type: 'credentials',
		credentials: {
			tokenURL: 'http://my-reso-api.com/token',
			clientId: 'MY_CLIENT_ID',
			clientSecret: 'MY_CLIENT_SECRET',
			// Optional: grantType and scope
		},
		// Optional: Custom refresh buffer (default is 30,000ms / 30 seconds)
		// refreshBuffer: 40000,
	},
});

Types Safety (Typescript)

For an enhanced development experience, you can pass a generic type to createFeed to auto type the client to your resources shapes, enabling full type-safety for all operations.

import { createFeed } from 'reso.js';

// 1. Define the TypeScript interface for your RESO resources.
// This generic type maps resource names (e.g., 'Property') to their expected shape.
interface Resources {
	Property: {
		ListingId: string;
		ListPrice: number;
		// ... all other expected properties
	};
	Agent: { Name: string };
}

// 2. Create the feed instance, applying the Resources generic.
const feed = createFeed<Resources>({
	http: {
		baseURL: 'http://my-reso-api.com',
	},
	// ... config
});

// 3. Read a specific resource by ID.
// Because the feed is typed with <Resources>, the 'Property' resource
// and the 'myProperty' response are fully type-safe, preventing runtime errors.
const myProperty = await feed.readById('Property', 123);

// This access is now guaranteed to be type-safe!
console.log(myProperty.data.ListingId);

Querying the API

readByQuery

Perform a RESO-compliant query. The function is an async generator that handles auto pagination for you. Use a for await...of loop to iterate through all pages of results.

for await (let properties of feed.readByQuery('Property', '$filter=ListPrice gt 100000')) {
	for (property of properties.data) {
		console.log(property);
	}
}

readById

Retrieve a specific record by ID:

const myProperty = await feed.readyById('Property', 123);
console.log(myProperty.data);

Fetching $metadata

Get the feed’s metadata XML:

const metadata = await feed.$metadata();
console.log(metadata); // The raw XML string

Rate Limiting

Rate limiting is built-in for supported providers. You can also customize limits:

| Parameter | Type | Description | | :------------- | :------------ | :------------------------------------------------ | | duration | number (ms) | The time window for the limit. | | points | number | The maximum requests allowed within the duration. |

const feed = createFeed({
	http: {
		baseURL: 'http://my-reso-api.com',
	},
	limiter: {
		duration: 30000, // 30 seconds
		points: 5, // max 5 requests per duration
	},
});

duration defines the time window in milliseconds, and points sets the maximum number of requests allowed within that window.

Hooks

Customize the client's behavior by passing an object of supported hooks (based on ofetch interceptors).

The clients behaviour can be customized with the following supported hooks:

| Hook | Purpose | | :---------------- | :---------------------------------------------------- | | onRequest | Modify the request before it's sent. | | onRequestError | Handle errors during the request setup. | | onResponse | Inspect/Modify the response data after it's received. | | onResponseError | Handle HTTP errors (e.g., 4xx, 5xx) before throwing. |

Example – Appending /replication to Property requests:

hooks: {
  onRequest: [
    ({ request }) => {
      if (request.toLowerCase().includes('property')) {
        request += '/replication';
      }
    },
  ],
},

Error Handling

The client throws a custom FeedError with detailed RESO error information:

try {
	const myProperty = await feed.readById('Property', 123);
	console.log(myProperty.data);
} catch (error) {
	if (error instanceof FeedError) {
		console.log(error.details);
	}
}

Contributing

Bug reports, pull requests and feature discussions are welcome at GitHub

License

MIT License