Similar homes
Show homes like the one a visitor is viewing, ranked best match first with the reasons, on listing pages and on the page of a listing that has left the market.
GET /v1/listings/{listingId}/similar returns homes like one listing, best match first. Use it for a
"Similar homes" strip on a listing page, and on the page of a listing that just left the market.
curl -s -G "https://idx.ruuster.com/v1/listings/aaaaaaaa-0000-4000-8000-000000000001/similar" \
--data-urlencode limit=6 \
-H "Authorization: Bearer $IDX_SECRET_KEY"import { createClient } from "@ruuster/idx";
const idx = createClient({ secretKey: process.env.IDX_SECRET_KEY });
const r = await idx.similar("aaaaaaaa-0000-4000-8000-000000000001", {
limit: 6,
});
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/aaaaaaaa-0000-4000-8000-000000000001/similar",
params={
"limit": "6",
},
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([
'limit' => '6',
], '', '&', PHP_QUERY_RFC3986);
$ch = curl_init('https://idx.ruuster.com/v1/listings/aaaaaaaa-0000-4000-8000-000000000001/similar' . '?' . $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']);How homes are matched
Candidates come from the same boards and the same type of home as the listing, priced within 20% of it,
within one bedroom and within 25% of its living area, in a box around it that widens once when it
finds too few. The listing itself is left out. Each match comes with why, the reasons it ranked
where it did:
| Field | What it says |
|---|---|
score |
0 to 100, higher is more similar |
distanceMiles |
Miles from the listing, or null when either address is hidden |
priceGapPct, sqftGapPct |
How much higher or lower the price and the living area are, in percent |
bedsDiff, bathsDiff |
How many more or fewer bedrooms and bathrooms |
sameSubtype |
Whether it is the same kind of home, such as a condo |
ageDays |
Days since it was listed, or since it sold |
data.area says how candidates were found: box (around the listing; data.widened is true when the
box grew), zip (the listing's ZIP code, for a listing whose address is hidden) or shape.
Options
limit: up to 12, and 6 when you leave it out.include=soldadds recent sales on the boards that show sold data.include=sold_onlyreturns recent sales alone.data.includesays which you got:active,active_and_soldorsold.maxMiles: how far from the listing a home may be, from 0.25 to 5 miles, and 5 when you leave it out. The search starts at 1.5 miles, or atmaxMileswhen that is smaller, and widens once up tomaxMileswhen it finds too few. When you send it, homes past that distance are left out, and so are homes whose address is hidden, because their distance can't be measured. It has no effect for a listing whose own address is hidden (its ZIP code is searched) or withshape.maxPriceGapPct: how far a home's price may be from the listing's, in percent either way, from 1 to 50, and 20 when you leave it out.shape=shp_…looks only inside one of your saved shapes.detailHrefsets the links, as on search.
Listings that left the market
When a listing leaves the market, its own detail call answers 410 listing_removed. For 30 days after
that, /similar still answers for it, with data.subjectRemoved set to true, so the "no longer
available" page can offer homes like it. After 30 days it answers 410 too.
Off-market and removed listings has the whole
page.
Showing them
Similar homes are listing cards like any other, so ListingGrid shows them with their attribution, and
the page shows the disclaimers in meta.mls. Don't put calls to action on the cards; they belong on
the listing page itself.