Nov 20, 20265 min read

Build a Real Estate Listing Sync Backend

Build the backend that keeps property listings in sync with an MLS or partner feed: incremental pulls by modification timestamp, upserts that tolerate re-delivery, photo copying to your own bucket, status changes, removals and change events for search and alerts. In TypeScript on Postgres.

Illustration for Build a Real Estate Listing Sync Backend

Listing data does not belong to the app that shows it. Prices change, homes go under contract, photos are replaced and listings are withdrawn, all in a feed owned by an MLS or a brokerage partner, and your site has to follow within minutes.

A sync backend is mostly careful bookkeeping: pull only what changed, apply it safely more than once, copy the photos and tell the rest of the system. This guide builds it in TypeScript on Postgres.

How do MLS feeds work?

Most MLSs now expose data through the RESO Web API, a standard built on OData that replaced RETS. It defines a Property resource with standardized field names such as ListingKey, StandardStatus, ListPrice and ModificationTimestamp, and supports filters and paging, so a query looks like Property?$filter=ModificationTimestamp gt 2026-11-20T08:00:00Z&$orderby=ModificationTimestamp&$top=200.

Access terms come from each MLS: credentials, rate limits, display rules and how long you may keep removed listings. Read your data license before designing retention, because it is a legal constraint, not a technical choice.

How do you pull only what changed?

Keep a high-water mark: the greatest ModificationTimestamp you have fully processed. Each run asks for records modified after that mark, in ascending order, and pages until empty. Advance the mark only after the batch is saved, so a crash re-reads some records instead of skipping them. Several listings can share a timestamp, so filter with ge and rely on idempotent upserts, or tie-break on ListingKey.

Feeds lie in small ways: a record occasionally changes without its timestamp moving. A nightly full reconciliation, comparing the set of active keys in the feed with your table, repairs drift and finds removals.

How do you apply updates safely?

Upsert by ListingKey with INSERT ... ON CONFLICT (listing_key) DO UPDATE, and keep the raw payload in a JSONB column next to the fields you query, so a mapping change can be replayed without refetching. Write only when something changed, by comparing a hash of the payload, so downstream consumers are not woken for no-ops. Status is data: store StandardStatus values such as Active, Pending and Closed, and mark listings missing from reconciliation as removed instead of deleting them.

What about photos?

Feed photo URLs often expire or sit on slow servers, and some licenses require you to host your own copies. Copy each photo into your own bucket under a key built from the listing key and photo order, and serve from there. Do the copying in a queue worker, since a listing can have fifty photos, and make it idempotent by skipping keys that already exist.

Building it with Encore

Encore

Encore is a backend framework with built-in infrastructure. The sync service declares its Postgres database, a cron job for the incremental pull, a bucket for photos and a Pub/Sub topic for change events in TypeScript, and Encore provisions them on AWS or GCP in your own account. The feed credentials are an Encore secret.

Set up the app

Get started
brew install encoredev/tap/encore &&
encore app create
Copy

Run in your terminal to get started locally.

-- listings/migrations/1_create_tables.up.sql CREATE TABLE listings ( listing_key TEXT PRIMARY KEY, status TEXT NOT NULL, list_price BIGINT, payload JSONB NOT NULL, payload_hash TEXT NOT NULL, modified_at TIMESTAMPTZ NOT NULL, removed_at TIMESTAMPTZ ); CREATE TABLE sync_state ( id INT PRIMARY KEY DEFAULT 1 CHECK (id = 1), high_water TIMESTAMPTZ NOT NULL ); INSERT INTO sync_state (id, high_water) VALUES (1, '1970-01-01');
// listings/listings.ts import { api } from "encore.dev/api"; import { secret } from "encore.dev/config"; import { SQLDatabase } from "encore.dev/storage/sqldb"; import { Topic } from "encore.dev/pubsub"; import { CronJob } from "encore.dev/cron"; import log from "encore.dev/log"; import { createHash } from "node:crypto"; const db = new SQLDatabase("listings", { migrations: "./migrations" }); const feedToken = secret("MlsFeedToken"); const FEED = "https://api.mls.example/reso/odata/Property"; interface ListingChanged { listingKey: string; status: string; } export const listingChanged = new Topic<ListingChanged>("listing-changed", { deliveryGuarantee: "at-least-once", }); interface Property { ListingKey: string; StandardStatus: string; ListPrice?: number; ModificationTimestamp: string; } export const sync = api({ expose: false }, async (): Promise<{ changed: number }> => { const state = await db.queryRow<{ high_water: Date }>`SELECT high_water FROM sync_state WHERE id = 1`; let since = state!.high_water.toISOString(); let changed = 0; for (;;) { const url = `${FEED}?$filter=${encodeURIComponent(`ModificationTimestamp ge ${since}`)}` + `&$orderby=ModificationTimestamp&$top=200`; const res = await fetch(url, { headers: { Authorization: `Bearer ${feedToken()}` } }); if (!res.ok) throw new Error(`feed returned ${res.status}`); const { value } = (await res.json()) as { value: Property[] }; if (value.length === 0) break; for (const p of value) { const hash = createHash("sha256").update(JSON.stringify(p)).digest("hex"); const row = await db.queryRow<{ listing_key: string }>` INSERT INTO listings (listing_key, status, list_price, payload, payload_hash, modified_at) VALUES (${p.ListingKey}, ${p.StandardStatus}, ${p.ListPrice ?? null}, ${JSON.stringify(p)}::jsonb, ${hash}, ${p.ModificationTimestamp}::timestamptz) ON CONFLICT (listing_key) DO UPDATE SET status = EXCLUDED.status, list_price = EXCLUDED.list_price, payload = EXCLUDED.payload, payload_hash = EXCLUDED.payload_hash, modified_at = EXCLUDED.modified_at, removed_at = NULL WHERE listings.payload_hash <> EXCLUDED.payload_hash RETURNING listing_key`; if (row) { changed++; await listingChanged.publish({ listingKey: p.ListingKey, status: p.StandardStatus }); } } const last = value[value.length - 1].ModificationTimestamp; await db.exec`UPDATE sync_state SET high_water = ${last}::timestamptz WHERE id = 1`; if (last === since) break; // a full page at one timestamp would loop forever since = last; } log.info("listing sync finished", { changed }); return { changed }; }); const _sync = new CronJob("listing-sync", { title: "Pull changed listings", every: "10m", endpoint: sync, });

The upsert only writes when the payload hash differs, so re-reading the overlap at the high-water mark publishes no duplicate events. Photo copying fits as a subscriber on listingChanged that downloads each photo and writes it to a bucket. Encore cron jobs run in cloud environments and not under encore run or in preview environments, so call sync from the local development dashboard when testing against a feed sandbox. The sync loop stops if a whole page shares one timestamp, so pick a page size above the number of listings your feed can change in one instant, or tie-break on ListingKey. Encore secret values are not stored in the repository or in git.

A coding agent can add a field to the mapping and its column in one change, replay the stored payloads locally, and let the deploy provision any new bucket or topic.

Best fit: Proptech teams building listing search or alerts in TypeScript who want an incremental feed sync with Postgres, photos in their own bucket and change events in their own AWS or GCP account.

Frequently asked questions

How do you sync listings from an MLS feed?

Pull incrementally with a filter on the modification timestamp, such as ModificationTimestamp gt the last successful sync, upsert each record by its listing key and record the new high-water mark only after the batch is saved. A periodic full reconciliation catches records the incremental pull missed.

What is the RESO Web API?

The RESO Web API is the real estate industry's standard for exchanging listing data over HTTP, built on OData. It defines the Property resource and standard field names, and replaced RETS at most MLSs, so one client can query several MLSs with the same fields and filters.

How do you handle removed or sold listings?

Treat status as data. Store the StandardStatus value from each update, and mark listings as removed when they stop appearing in a full reconciliation, rather than deleting rows, so saved searches, alerts and history keep working.

How do I build a listing sync with Encore?

A TypeScript service declares the Postgres database, a cron job that runs the incremental sync, an object storage bucket for photos and a Pub/Sub topic for change events, and Encore provisions them in your AWS or GCP account. Cron jobs run in cloud environments, so trigger the sync endpoint by hand when testing locally.

Deploy to your cloud on AWS and Google Cloud
without managing infrastructure

Encore lets developers and agents define application infrastructure directly in code, then automatically provisions it from local development to production in your AWS or GCP account.

~/orders — claude
Claude Code
Claude Code v2.1.180Opus 5.5~/orders