Zillow API Wrapper for Node.js
The `node-zillow` package provides a straightforward Node.js wrapper for the Zillow API, abstracting away the complexities of HTTP requests and XML parsing to return data via promises. Its current stable version is 2.0.0, released in 2018, indicating an infrequent release cadence focused on stability rather than rapid feature additions. The library consolidates all Zillow API interactions through a single `get` method, taking the API call name and parameters, offering a consistent interface. It relies on a Zillow Web Service ID (ZWSID) for authentication. Developers must refer to the official Zillow API documentation for available endpoints and parameters, as this library primarily acts as a thin client. Key features include promise-based asynchronous operations (using the `Q` library) and handling various Zillow API endpoints like `GetZestimate` or `GetDeepSearchResults`. The library does not handle Zillow's API terms of use or branding requirements, which developers are explicitly reminded to follow.
Common errors
-
Error: ZWSID not provided
cause The Zillow client was instantiated without a valid Zillow Web Service ID (ZWSID) or an empty string was passed.fixProvide your Zillow Web Service ID during instantiation: `new Zillow('YOUR_ZWSID', options)` or ensure `process.env.ZWSID` is correctly set. -
TypeError: Zillow is not a constructor
cause Attempted to call `Zillow` as a function without the `new` keyword after requiring it.fixInstantiate the `Zillow` class using `new`: `const zillow = new Zillow(zwsid);` -
Zillow API Error: 5003 - Invalid ZWSID
cause The Zillow Web Service ID provided is either incorrect, revoked, has not been approved for the specific API endpoint, or has reached its daily request limit.fixVerify your ZWSID on the Zillow developer portal. Ensure it is active, correctly entered, and authorized for the API calls you are making. Check your daily API usage limits. -
TypeError: Cannot read properties of undefined (reading 'response')
cause The Zillow API call returned a result object that did not contain the expected `response` property, leading to an attempt to access `undefined.response`.fixAlways check for the existence of the `response` property before attempting to access it, as it's not guaranteed in all Zillow API responses: `if (results && results.response) { /* process response */ }`.
Warnings
- breaking Version 1.0.0 removed all direct API method wrappers (e.g., `Zillow.getDeepSearchResults()`) in favor of a single, unified `get` method for all Zillow API calls.
- breaking Version 2.0.0 dropped explicit support for Node.js v0.10.x and updated internal dependencies. Running this package in very old Node.js environments may lead to compatibility issues.
- gotcha The Zillow API's response object might not always include the `response` property, even for successful calls depending on the specific endpoint and data availability. Always check for its existence.
- gotcha The `https` option for API requests defaults to `false` if not explicitly set during instantiation (`new Zillow(zwsid, options)`). This means API requests could be made over insecure HTTP, exposing your ZWSID and potentially sensitive data.
- gotcha Usage of the Zillow API via this wrapper is subject to Zillow's API Terms of Use and Branding Requirements. Failure to comply can result in API key revocation or legal action.
- deprecated The library internally uses the 'Q' promise library. While this doesn't directly affect the consumer if using standard promise `.then()` and `.catch()`, 'Q' is generally considered a legacy promise implementation superseded by native Promises in modern Node.js environments. This might affect advanced promise interop.
Install
-
npm install node-zillow -
yarn add node-zillow -
pnpm add node-zillow
Imports
- Zillow
import { Zillow } from 'node-zillow';const Zillow = require('node-zillow'); - new Zillow()
const zillow = Zillow(process.env.ZWSID);
const zillow = new Zillow(process.env.ZWSID);
- get
Zillow.get('GetSearchResults', parameters);zillow.get('GetSearchResults', parameters);
Quickstart
const Zillow = require('node-zillow');
// It's highly recommended to use environment variables for sensitive IDs.
// For demonstration, use a placeholder or actual ID if safe.
const zwsid = process.env.ZWSID ?? 'YOUR_ZWSID_HERE'; // Replace with a valid ZWSID for actual use
if (!zwsid || zwsid === 'YOUR_ZWSID_HERE') {
console.error('Error: ZWSID not provided. Please set ZWSID environment variable or replace placeholder.');
process.exit(1);
}
// Instantiate the Zillow client, explicitly enabling HTTPS for secure communication.
const zillow = new Zillow(zwsid, { https: true });
// Define parameters for the Zillow API call. Example for GetZestimate.
const parameters = {
zpid: 1111111 // Example Zillow Property ID
};
console.log(`Attempting to get Zestimate for ZPID: ${parameters.zpid}`);
zillow.get('GetZestimate', parameters)
.then(function(results) {
// Zillow API responses can vary; 'response' property might not always be present.
if (results && results.response) {
console.log('Successfully retrieved Zestimate:');
console.log(JSON.stringify(results.response, null, 2));
} else if (results && results.message) {
console.error('Zillow API Message:', JSON.stringify(results.message, null, 2));
} else {
console.error('Unexpected Zillow API response structure:', JSON.stringify(results, null, 2));
}
})
.catch(function(error) {
console.error('An error occurred during Zillow API call:', error.message);
if (error.response && error.response.data) {
console.error('Detailed error response:', error.response.data);
}
});