apidata.one docs Get a key

Build an SEO-friendly site

Search engines may index your listing pages: Bright's IDX rules allow it. This guide shows how to build pages a search engine can read, with addresses that last, a sitemap, and removal that stays prompt, all within Bright's display rules (compliance).

The short version:

  1. Build each page on your server, with your secret key.
  2. Give each listing one address, by its listingKey.
  3. Write the title, the description and the structured data only from fields the API returned.
  4. Build your sitemap from the key list.
  5. Answer 410 Gone for a listing that was removed, and drop every stored copy of it.

Build pages on the server

A page that fills itself in the browser, with a publishable key, is an empty page to many crawlers. Build listing pages and search pages on your server instead:

// A listing page, built on the server (Node 24, any framework).
app.get('/listing/:listingKey/:words?', async (req, res) => {
  const r = await fetch(`https://api.apidata.one/v1/listings/${encodeURIComponent(req.params.listingKey)}`, {
    headers: { Authorization: `Bearer ${process.env.APIDATA_SECRET_KEY}` },
  });
  if (r.status === 404) return res.status(removedKeys.has(req.params.listingKey) ? 410 : 404).send(gonePage());
  if (!r.ok) return res.status(503).set('Retry-After', r.headers.get('retry-after') ?? '300').send(busyPage());
  const { data: listing, compliance } = await r.json();
  const canonical = listingPath(listing);
  if (req.path !== canonical) return res.redirect(301, canonical); // the address changed: one address a listing
  res.send(listingPage(listing, compliance, canonical));
});

One address for each listing

Use the listingKey to find a listing, never its street address:

// The slug ends with "-" and the listing key: cut that off to get the words.
function listingPath(listing) {
  const words = listing.slug.slice(0, -(listing.listingKey.length + 1));
  return `/listing/${listing.listingKey}/${words}`;
}
// /listing/805454359664/101-main-st-ardmore-pa-19003
// /listing/805454361120/ardmore-pa            (a hidden address: city and state only)

Titles, descriptions and structured data

Write them from the listing as the API returned it, at that moment:

function listingTitle(l) {
  const where = l.address
    ? `${l.address.line1}, ${l.address.city}, ${l.address.state} ${l.address.postalCode}`
    : `${l.statusLabel} listing`; // a hidden address: no street, in any tag
  const price = l.price.list === null ? '' : ` | $${l.price.list.toLocaleString('en-US')}`;
  return `${where}${price}`;
}
function listingJsonLd(l, url) {
  const data = {
    '@context': 'https://schema.org',
    '@type': 'RealEstateListing',
    url,
    name: listingTitle(l),
    dateModified: l.updatedAt,
    image: l.photos.primary ? [l.photos.primary.full ?? l.photos.primary.medium].filter(Boolean) : [],
  };
  if (l.price.list !== null) data.offers = { '@type': 'Offer', price: l.price.list, priceCurrency: 'USD' };
  if (l.address)
    data.about = {
      '@type': 'Residence',
      address: {
        '@type': 'PostalAddress',
        streetAddress: l.address.line1,
        addressLocality: l.address.city,
        addressRegion: l.address.state,
        postalCode: l.address.postalCode,
      },
      ...(l.location ? { geo: { '@type': 'GeoCoordinates', latitude: l.location.lat, longitude: l.location.lng } } : {}),
    };
  return JSON.stringify(data).replace(/</g, '\\u003c'); // safe inside a <script> tag
}

Every page built on the server carries the same disclosures as any other page with listings: the compliance texts, your brokerage's name, and the listing office's name and contact near the top of a detail page (what goes where). Photos keep object-fit: contain.

A sitemap from the key list

GET /v1/listings/keys lists every listing the API serves, by key, with the time it last changed. It is for your server, with the secret key:

// Every key the API serves, with when each last changed. About 210 requests for a million keys.
async function allKeys() {
  const out = [];
  let cursor = null;
  for (;;) {
    const url = new URL('https://api.apidata.one/v1/listings/keys');
    url.searchParams.set('limit', '5000');
    if (cursor) url.searchParams.set('cursor', cursor);
    const r = await fetch(url, { headers: { Authorization: `Bearer ${process.env.APIDATA_SECRET_KEY}` } });
    if (r.status === 429) {
      await new Promise((done) => setTimeout(done, 1000 * Number(r.headers.get('retry-after') ?? 2)));
      continue; // the same page again
    }
    if (!r.ok) throw new Error(`key list: ${r.status}`);
    const page = await r.json();
    out.push(...page.data); // { listingKey, updatedAt }
    cursor = page.meta.page.nextCursor;
    if (cursor === null) return out;
  }
}

Caching and prompt removal

A removed listing must leave your site at once, stored pages included. So store as little as you can, for as short a time as you can:

What to answer for a listing that is gone

The listing Answer Why
Removed from the data, and you know it: you got its listing.removed notice, or you served it before and it is missing from the key list 410 Gone, with a plain page and links to search It tells a search engine to drop the page for good
Never existed, or you can't tell: the API answers 404 listing_not_found for both, so a key you never served is this case 404 Not Found A 410 for an address that never was a page tells a search engine nothing
Live data is stopped (data_stale), or the API can't be reached 503 with Retry-After The page stays indexed

A 410 page shows nothing of the listing: no address, no photo, no price.

Crawlers count against your limits

Every page a crawler fetches makes your server call the API, and those calls count against your secret key's limits like any others. A crawler that takes thousands of pages in a burst can use up the bucket your visitors share.

See it working

The sample site at demo.apidata.one is built this way, on a sandbox key: pages built on the server, addresses by listingKey, a sitemap from the key list, 410 for a removed listing, and every disclosure.

Checklist

This page as Markdown