# Keeping pages fresh: ids, changes and webhooks

Source: https://help.ruuster.com/idx/guide-freshness

> Keep server-rendered pages current with the listing ids feed for sitemaps, the change feed and listing-change webhooks, and re-render only what changed.

Prices and statuses change through the day, and listings leave the market. Three tools keep your pages
current, and you can use them together.

| Tool | Use it for | Key |
|---|---|---|
| `GET /v1/listings/ids` | Your listing sitemap, and a full resync | Secret |
| `GET /v1/changes` | Polling for what changed since your last call | Secret |
| Listing-change webhooks | Being told within minutes, without polling | None. Each delivery is signed |

The simplest setup: cache pages for five minutes (ISR or your CDN), rebuild the sitemap hourly from
the ids feed, and add the webhook so changed listings re-render at once.

## The listing ids feed

`/v1/listings/ids` walks every listing your boards let you show, a page at a time. Each row has the
listing's `id`, `slug`, `mlsNumber`, `mls`, `updatedAt` and `modifiedAt`.

cURL:

```bash
curl -s -G "https://idx.ruuster.com/v1/listings/ids" \
  --data-urlencode limit=1000 \
  -H "Authorization: Bearer $IDX_SECRET_KEY"
```

TypeScript:

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

const idx = createClient({ secretKey: process.env.IDX_SECRET_KEY });

const r = await idx.ids({
  limit: 1000,
});
if (!r.ok) throw new Error(`${r.error.code}: ${r.error.message}`);
console.log(r.data);
```

Python:

```python
import os

import requests

res = requests.get(
    "https://idx.ruuster.com/v1/listings/ids",
    params={
        "limit": "1000",
    },
    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:

```php
<?php

$query = http_build_query([
    'limit' => '1000',
], '', '&', PHP_QUERY_RFC3986);
$ch = curl_init('https://idx.ruuster.com/v1/listings/ids' . '?' . $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']);
```

Follow `nextCursor` until it is null. Build each URL from `slug` with your detail template, and use
`modifiedAt` as the sitemap's `lastmod` (`updatedAt` also moves when nothing a page shows changed). A
cursor is tied to your boards: when they change, the API refuses it, and you start the walk again.
[Step 5 of the SEO guide](https://help.ruuster.com/idx/guide-seo-ai-answers) has the sitemap code.

## The change feed

`/v1/changes` answers what changed since a time, then since each cursor. Send `since` (an ISO time
within the last seven days) on the first call, then the `nextCursor` of each answer.

cURL:

```bash
curl -s -G "https://idx.ruuster.com/v1/changes" \
  --data-urlencode since=2026-10-21T15:00:00Z \
  --data-urlencode limit=500 \
  -H "Authorization: Bearer $IDX_SECRET_KEY"
```

TypeScript:

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

const idx = createClient({ secretKey: process.env.IDX_SECRET_KEY });

const r = await idx.changes({
  since: "2026-10-21T15:00:00Z",
  limit: 500,
});
if (!r.ok) throw new Error(`${r.error.code}: ${r.error.message}`);
console.log(r.data);
```

Python:

```python
import os

import requests

res = requests.get(
    "https://idx.ruuster.com/v1/changes",
    params={
        "since": "2026-10-21T15:00:00Z",
        "limit": "500",
    },
    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:

```php
<?php

$query = http_build_query([
    'since' => '2026-10-21T15:00:00Z',
    'limit' => '500',
], '', '&', PHP_QUERY_RFC3986);
$ch = curl_init('https://idx.ruuster.com/v1/changes' . '?' . $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']);
```

Each row has a `kind`:

- `upsert`: the listing is new or changed. Re-render its page. `change` says what changed
  (`created`, `price_changed`, `status_changed` or `updated`), with `previous` and `current` price and
  status where the history has them.
- `removed`: the listing left the market or your scope. Its page answers 410 from now on; drop it from
  your sitemap.
- `scope_removed`: a whole board left your key's scope. `id` is that board's id. Drop every listing
  whose `mls` is that id.

How to poll:

- Call again at once while `hasMore` is true, and again in a few minutes when it is false. A page can be
  short, even empty, while more is waiting, so follow `hasMore`, not the row count.
- Delivery is at least once: a listing can repeat, and a removal can be reported again. Treat every row
  as idempotent; re-rendering twice is harmless.
- A cursor is valid for seven days. An older one answers 410 `cursor_expired`: rebuild from the ids
  feed, then call `/v1/changes` with `since` set to 15 minutes before you started the rebuild.

## Webhooks

A listing-change webhook calls your server when a listing in your boards is created, changes price,
changes status or is removed, so you don't poll at all.
[Listing-change webhooks](https://help.ruuster.com/idx/guide-webhooks) covers setup, signatures,
retries and batches.

## Re-rendering cheaply

- In Next.js, `revalidatePath` re-renders one page on its next request. The webhook route in the
  examples repo does this for each changed listing and for your area pages.
- A listing answer carries an `ETag`. Send it back as `If-None-Match` when you check a page: a `304 Not
  Modified` costs no units.
- Re-render the area pages a changed listing appears on, too: their counts and cards change with it.

[How current the data is](https://help.ruuster.com/idx/guide-data-freshness) explains how quickly a
change on a board reaches the API.
