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.
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"import { createClient } from "@ruuster/idx";
const idx = createClient({ secretKey: process.env.IDX_SECRET_KEY });
const r = await idx.search({
zip: "30308",
status: "closed",
soldPeriod: "6m",
sort: "close_date_desc",
limit: 24,
});
if (!r.ok) throw new Error(`${r.error.code}: ${r.error.message}`);
console.log(r.data);import os
import requests
res = requests.get(
"https://idx.ruuster.com/v1/listings",
params={
"zip": "30308",
"status": "closed",
"soldPeriod": "6m",
"sort": "close_date_desc",
"limit": "24",
},
headers={"Authorization": "Bearer " + os.environ["IDX_SECRET_KEY"]},
timeout=30,
)
body = res.json()
if not body["ok"]:
raise RuntimeError(body["error"]["code"] + ": " + body["error"]["message"])
print(body["data"])<?php
$query = http_build_query([
'zip' => '30308',
'status' => 'closed',
'soldPeriod' => '6m',
'sort' => 'close_date_desc',
'limit' => '24',
], '', '&', PHP_QUERY_RFC3986);
$ch = curl_init('https://idx.ruuster.com/v1/listings' . '?' . $query);
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ['Authorization: Bearer ' . getenv('IDX_SECRET_KEY')],
CURLOPT_TIMEOUT => 30,
]);
$body = json_decode(curl_exec($ch), true);
curl_close($ch);
if (!$body['ok']) {
throw new RuntimeException($body['error']['code'] . ': ' . $body['error']['message']);
}
print_r($body['data']);soldPeriodnever 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
closePriceas a closed listing's sold price (the recipe components do).closeDateis the sale date: format it withfmt.date, which keeps a date sent as midnight UTC on its own day.listPriceis the original asking price when the board sends it, andpriceis normally the sold price as well. status=closedwithoutsoldPeriodanswers 400sold_period_required.- A sold search covers only the boards that show sold data. When a search mixes
closedwith other statuses and its boards disagree, it answers 422sold_not_permitted: narrow it withfilterByMlsto the boards that show sold data, or dropclosed.
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.titledoes 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.