# Price history, agent production and building on our data

Source: https://help.ruuster.com/idx/guide-build-on-our-data

> Price history, an agent's production, and the extension points that let your own AI add fields to our listings and photos (photo ids, photo change events, your own fields and an enrichment hook).

Two answers came out of rebuilding a large brokerage site on the API: a listing's price history, and
an agent's production for "where they've sold" on a profile page. Both are on for every account.

Beside them sit the extension points: the pieces that let you build features we don't, such as photos
grouped by room or a condition score, with your own AI on your own key. Ruuster never labels or
changes photos itself.

## Price history

`GET /v1/listings/{listingId}/history` returns the listing's events, newest first: `listed`,
`price_change`, `status_change`, `sold` and `back_on_market`, each with the price and status after it
and before it. Statuses your MLS doesn't let you show (withdrawn, expired) are never named, and a sale
appears only where the MLS shows sold data, inside its sold window. With the SDK:
`await idx.history(listingId)`.

## An agent's production

`GET /v1/agents/{agentMlsId}/production` takes the agent's MLS id (the member id their board issued)
and returns their listings for sale now, counted by status with up to 100 ids, and the homes they
sold (on either side, where the MLS allows the buyer side) over up to 36 months, for your own brokerage's agents only: the count, the volume, and the top 25 cities and ZIP codes.
Each MLS caps the months at its own sold window (`period.soldFrom`). Send `mls` with the board's id
when your account has more than one board. With the SDK: `await idx.agentProduction("A1234", { months: 36 })`.
Your AI assistant can ask for it through the MCP tool `listings_agent_production`.

## Extension points

These are turned on per account. Ask `helpme@ruuster.com` (or call 312-948-5402) before you build on
them: each one is off until we turn it on for you, and your fields and hook work once your go-live
request has linked your brokerage. Once they are on, you (or your AI assistant) set up your fields and
your hook yourself with the setup commands: `npx @ruuster/idx setup field`, `setup fields`,
`setup field-remove`, `setup hook`, `setup hook-test` and `setup hook-remove`. An assistant connected
through MCP can list, define and remove fields and test or remove the hook; registering the hook is
done with the command, because its signing secret goes straight into your `.env.local`.
[Setup actions for your AI assistant](https://help.ruuster.com/idx/setup-actions) lists every
command.

| Piece | What you get |
|---|---|
| Photo ids | Every photo on the listing and photos answers gains a stable `id` (`ph_` and 16 letters and digits) and `sizes` (480, 800 and 1200 pixels wide). |
| MLS captions | Alongside photo ids, where the MLS sends one, the photo's own `caption` and `room` come through unchanged. Few boards send them today. |
| Photo change events | `/v1/changes` rows with `change: "photos_changed"`, and a `listing.photos_changed` webhook you subscribe to by name, when the photos changed and the price and status didn't. |
| Your own fields | Fields you define (text, number, yes or no, or a fixed list of values) stored against our listing ids and photo ids, returned to your account only, under `custom` on the listing and photos answers. |
| Enrichment hook | We call your URL when a listing is new or changed and store what your code answers as your fields. |

### Your own fields

You define up to 20 fields, for example
`npx @ruuster/idx setup field room --target photo --type enum --values kitchen,bedroom,other`. Each has a key (lower-case letters, digits and underscores), a target
(`listing` or `photo`) and a type: `text` (up to 500 characters, plain text only), `number`,
`boolean` or `enum` (up to 50 short values). Anything else is refused: a value of the wrong type, a
key you didn't define, text with markup or control characters, or text over its length.

They come back as lists, so your code reads them the same way every time:

```json
"custom": {
  "listing": [{ "key": "condition_score", "value": 7.5 }],
  "photos": [{ "photoId": "ph_0123456789abcdef", "key": "room", "value": "kitchen" }]
}
```

Only your account ever sees your fields. Another account reading the same listing gets none of them.

### The enrichment hook

1. Deploy a route at a public `https` address on port 443 (the
   [recipe](https://help.ruuster.com/idx/recipe-photos-by-room) has one).
2. Register it: `npx @ruuster/idx setup hook https://your-server/hook --write .env.local` (add
   `--budget 500` for fewer calls a day). The signing secret is written into the file as
   `IDX_ENRICH_HOOK_SECRET` and shown nowhere else; registering again replaces the hook and its
   secret. `setup hook-test` sends one signed sample call. Each call carries `Ruuster-Signature:
   t=<unix seconds>,v1=<hex>`, the HMAC-SHA256 of `<t>.<body>`: check it and refuse anything older than
   5 minutes.
3. Each call sends the listing's id, MLS, status and photos (ids and URLs) and your field
   definitions. Answer within 8 seconds with `200` and `application/json`:
   `{ "listing": { "<key>": value }, "photos": { "<photo id>": { "<key>": value } } }`, at most 64 KB.

The rules: the address must be a public host name (never an IP address, and it must not resolve to a
private, loopback or link-local address); we follow no redirects; each account has a daily budget of
calls; and a hook that fails 20 calls in a row is turned off until you fix it. Your answer replaces
what your hook stored before for that listing.
