Whether you're building a browser-based tool or a Node.js backend service, integrating ZipMarketData takes just a few lines of code. This tutorial covers fetch, error handling, and a simple in-memory cache.

Browser (Vanilla JS)

const API_KEY = 'your_key'; const BASE = 'https://zipmarketdata.com'; async function getMarketStats(zipCode) { const res = await fetch(`${BASE}/market-stats?zip_code=${zipCode}`, { headers: { 'x-rapidapi-proxy-secret': API_KEY } }); if (!res.ok) throw new Error(`API error: ${res.status}`); return res.json(); } // Usage getMarketStats('90210') .then(d => console.log(`Median: $${d.median_sale_price.toLocaleString()}`)) .catch(console.error);

Node.js with Simple Cache

const https = require('https'); const cache = new Map(); const TTL = 24 * 60 * 60 * 1000; // 24 hours — matches data update frequency function getMarketStats(zipCode) { const cached = cache.get(zipCode); if (cached && Date.now() - cached.ts < TTL) return Promise.resolve(cached.data); return new Promise((resolve, reject) => { const options = { hostname: 'zipmarketdata.com', path: `/market-stats?zip_code=${zipCode}`, headers: { 'x-rapidapi-proxy-secret': process.env.ZIPMARKETDATA_KEY } }; https.get(options, res => { let body = ''; res.on('data', chunk => body += chunk); res.on('end', () => { const data = JSON.parse(body); cache.set(zipCode, { data, ts: Date.now() }); resolve(data); }); }).on('error', reject); }); }