Menu · Guides
Guides

Sold listings and sold windows

Search recently sold homes on the boards that show sold data, within each board's sold window, and build sold pages that stay correct when a board's rules differ.

View as Markdownopenapi.json

Some boards let you show sold listings for a period after the sale, and some don't show sold listings at all. The API applies each board's rule, so you never show a sale a board doesn't allow.

Check first

GET /v1/meta answers data.capabilities.sold: one row per board with mlsId, allowed and windowDays (how many days after the sale a listing may be shown). Build a sold page only when at least one of your boards allows sold data; otherwise link to the area's listings for sale instead.

To name those boards, match each row's mlsId with the id of a board in data.mls from the same answer, which holds its name:

import { createClient } from "@ruuster/idx";

const idx = createClient({ secretKey: process.env.IDX_SECRET_KEY });
const m = await idx.meta();
if (m.ok) {
  const names = new Map(m.data.mls.map((b) => [b.id, b.name]));
  for (const row of m.data.capabilities.sold) {
    console.log(names.get(row.mlsId) ?? row.mlsId, row.allowed ? `${row.windowDays} days` : "no sold data");
  }
}

A sold page needs no list of which boards cover which area. A search with status=closed alone answers from those of your boards that show sold data. When none of your boards does, it answers 422 sold_not_permitted; when the area's own boards show no sold data, it answers no listings. The Next.js example answers the first with a 404 and shows its empty-page sentence for the second.

Searching sold homes

Send status=closed with soldPeriod, which is how far back to look: 7d, 1m, 3m, 6m or 12m. Sort with close_date_desc for the most recent sales first.

curl -s -G "https://idx.ruuster.com/v1/listings" \
  --data-urlencode zip=30308 \
  --data-urlencode status=closed \
  --data-urlencode soldPeriod=6m \
  --data-urlencode sort=close_date_desc \
  --data-urlencode limit=24 \
  -H "Authorization: Bearer $IDX_SECRET_KEY"
  • soldPeriod never reaches further back than a board's own window: a board that shows 90 days of sales answers 90 days even when you ask for 12 months.
  • Show closePrice as a closed listing's sold price (the recipe components do). closeDate is the sale date: format it with fmt.date, which keeps a date sent as midnight UTC on its own day. listPrice is the original asking price when the board sends it, and price is normally the sold price as well.
  • status=closed without soldPeriod answers 400 sold_period_required.
  • A sold search covers only the boards that show sold data. When a search mixes closed with other statuses and its boards disagree, it answers 422 sold_not_permitted: narrow it with filterByMls to the boards that show sold data, or drop closed.

Sold listing pages

A sold listing's own page stays live and shows "Sold" until its board's sold window ends. After that, GET /v1/listings/{listingId} answers 410 listing_removed, and the page answers 410 too (Off-market and removed listings).

Writing sold pages

  • Title a sold page with what it shows, such as "Recently sold homes in Midtown". The API's head.title does this for you when the search is sold only.
  • Say these are recent sales in the area, not your brokerage's sales, unless you filtered to your own listings.
  • Print the date the data was last updated and every board's disclaimer, as on any results page.
  • Sold and status rules has the rules in full.

Market numbers for sales (median sold price, days on market) follow the same rule: Market stats by area.