The wrong way to build “new listing in this zip code” alerts is to poll Zillow every 60 seconds. The right way is webhooks plus a small worker.
The polling version hits rate limits and still misses events between polls. The webhook version stops polling for job results. New listings still arrive only as often as your searches run.
This post is the architecture, the working code, and the HMAC verification that keeps the webhook endpoint safe.
Why webhooks beat polling for listing alerts
Polling is a client-driven model where your application periodically calls a third-party API to check whether anything has changed. Webhooks are server-driven. The server pushes a notification when an event happens, and your client receives an HTTP POST.
The cost gap is real. According to research aggregated by Hookdeck and others, event-driven webhook architectures reduce server load by roughly 70 to 80 percent compared to polling for the same workload.
The latency gap is bigger. Polling cannot guarantee immediate updates. If an event happens right after a poll, you do not catch it until the next poll. The Real Estate Standards Organization has recommended webhooks as the path forward for MLS data delivery for exactly this reason.
The exception: if you are scheduling alerts on a sub-five-minute cadence, polling and webhooks converge in usefulness because most MLS feeds refresh every 5 to 15 minutes anyway.
Architecture in one diagram
[once: POST /v1/webhooks {url, events}]
[cron: every 30 min] │ ▼[POST /v1/listings/for-sale {filters, async: true, maxItems: 10}] │ │ 202 + job_id ▼[ZillAPI runs the search async] │ │ POST job event to your /webhooks/zillow ▼[your worker] ├─ verify HMAC signature ├─ GET /v1/jobs/{id}/results ├─ diff vs last_seen_zpids in db ├─ for each new zpid → enqueue notification └─ update last_seen_zpids │ ▼[push notification → user device / email / SMS]Five moving parts. Cron, async search, webhook handler, dedup table, notification queue. Each one is small.
Step 1: schedule the async search
Register your webhook once, with register_webhook below. It covers every job on your account. Keep your copy of the signing secret secure. Then run schedule_search on a cron. 30-minute granularity is a reasonable default for most listing-alert use cases.
Every run is billed again (1 credit per listing returned, minimum 1), so set the interval to what your product needs. You can tune this lower for premium tiers if your product needs sub-30-minute alerting.
import asyncio, os, requests
ZILLAPI = "https://api.zillapi.com/v1"HEADERS = {"Authorization": f"Bearer {os.environ['ZILLAPI_KEY']}"}
# db is your async database client, such as an asyncpg pool. It needs:# create table alert_jobs (job_id text primary key, filter_id text not null);
def register_webhook(url: str) -> str: """Run once. Store the returned secret as ZILLAPI_WEBHOOK_SECRET.""" r = requests.post( f"{ZILLAPI}/webhooks", json={ "url": url, # for example https://yourapp.example/webhooks/zillow "events": ["job.succeeded", "job.failed", "job.timed_out", "job.aborted"], }, headers=HEADERS, timeout=30, ) r.raise_for_status() return r.json()["data"]["secret"]
async def schedule_search(filter_id: str, bbox: dict, max_price: int, min_beds: int): body = { "filters": { "status": "for_sale", "daysOnZillow": "1", # listed in the last day "bbox": bbox, # {"west": -77.09, "south": 38.86, "east": -76.99, "north": 38.96} "price": {"max": max_price}, "beds": {"min": min_beds}, }, "maxItems": 10, "async": True, } r = await asyncio.to_thread( requests.post, f"{ZILLAPI}/listings/for-sale", json=body, headers={**HEADERS, "content-type": "application/json"}, timeout=30, ) r.raise_for_status() job_id = r.json()["data"]["job_id"] await db.execute( "insert into alert_jobs (job_id, filter_id) values ($1, $2)", job_id, filter_id, ) return job_idThe saved job_id tells your handler which user-saved filter a job event belongs to.
Step 2: verify the webhook signature
Every ZillAPI webhook carries X-Zillow-Signature: t=<unix>,v1=<hex>. The signing scheme follows the same pattern Stripe documents and the same one most major webhook providers use.
Recompute HMAC-SHA256 over <t>.<raw_body> with your webhook secret. Compare the result to the v1 value with a constant-time comparison.
Critical: use the raw bytes of the body, not a parsed JSON object. Whitespace and key order matter. Any framework that re-serializes the JSON before you compute the signature will break verification.
import asyncio, hmac, hashlib, os, re, time, jsonfrom fastapi import BackgroundTasks, FastAPI, Request, HTTPException
app = FastAPI()SECRET = os.environ["ZILLAPI_WEBHOOK_SECRET"]
@app.post("/webhooks/zillow")async def hook(request: Request, background: BackgroundTasks): raw = await request.body() header = request.headers.get("x-zillow-signature", "") m = re.fullmatch(r"t=([0-9]{1,12}),v1=([a-f0-9]{64})", header) if not m: raise HTTPException(401, "bad signature") ts, sig = m.group(1), m.group(2) if abs(time.time() - int(ts)) > 300: raise HTTPException(401, "stale signature") expected = hmac.new( SECRET.encode(), f"{ts}.{raw.decode()}".encode(), hashlib.sha256, ).hexdigest() if not hmac.compare_digest(sig, expected): raise HTTPException(401, "bad signature")
event = json.loads(raw) job_id, name = event["data"]["job"]["id"], event["event"] if name != "job.succeeded": print(f"{job_id}: {name}") # nothing to fetch return {"ok": True}
filter_id = await db.fetchval( "select filter_id from alert_jobs where job_id = $1", job_id ) if filter_id is None: raise HTTPException(503, "job not saved yet") # ZillAPI retries
# Save it as pending before answering 200. It is handled only once process_results succeeds. # create table handled_events (job_id text, event text, handled boolean not null default false, # claimed_at timestamptz, primary key (job_id, event)); await db.execute( "insert into handled_events (job_id, event) values ($1, $2) on conflict do nothing", job_id, name, ) background.add_task(process_job, job_id, filter_id) return {"ok": True}
async def process_job(job_id: str, filter_id: str): # Claim the pending job, so a repeat delivery and the cron never process it at the same time claimed = await db.fetchval( "update handled_events set claimed_at = now() " "where job_id = $1 and event = 'job.succeeded' and not handled " "and (claimed_at is null or claimed_at < now() - interval '5 minutes') returning true", job_id, ) if not claimed: return try: # The event carries job metadata only, so fetch the rows r = await asyncio.to_thread( requests.get, f"{ZILLAPI}/jobs/{job_id}/results", params={"limit": 10}, headers=HEADERS, timeout=30, ) r.raise_for_status() # An empty search can return one placeholder row with no zpid await process_results(filter_id, [row for row in r.json()["data"] if row.get("zpid")]) except Exception as error: await db.execute( "update handled_events set claimed_at = null where job_id = $1 and event = 'job.succeeded'", job_id, ) print(f"{job_id}: still pending, the cron retries it ({error})") return await db.execute( "update handled_events set handled = true where job_id = $1 and event = 'job.succeeded'", job_id, )
async def retry_pending(): """Run from the same cron, before schedule_search.""" for row in await db.fetch( "select e.job_id, j.filter_id from handled_events e " "join alert_jobs j using (job_id) where not e.handled" ): await process_job(row["job_id"], row["filter_id"])Three checks happen here. The signature header parses cleanly. The timestamp is within 300 seconds of now (replay protection). The recomputed HMAC matches the v1 value (authenticity).
The same verification logic in Node.js, Go, and other runtimes lives in our verify-webhook recipe.
Step 3: diff against the last run
You only want to notify users about properties they have not seen yet. Keep a seen_zpids table per filter.
create table seen_listings ( filter_id text not null, zpid text not null, first_seen_at timestamptz not null default now(), primary key (filter_id, zpid));The diff is set arithmetic.
async def process_results(filter_id: str, results: list[dict]): incoming_zpids = {str(r["zpid"]) for r in results}
rows = await db.fetch( "select zpid from seen_listings where filter_id = $1", filter_id, ) seen = {r["zpid"] for r in rows} new_zpids = incoming_zpids - seen if not new_zpids: return
new_listings = [r for r in results if str(r["zpid"]) in new_zpids] for listing in new_listings: await enqueue_notification(filter_id, listing) # Mark it seen only after it is queued, so a failure is retried await db.execute( "insert into seen_listings (filter_id, zpid) values ($1, $2) on conflict do nothing", filter_id, str(listing["zpid"]), )The handled flag and the claim are what make the handler idempotent. If ZillAPI retries the webhook (because your endpoint timed out or returned a non-2xx), a repeat of a handled event inserts no duplicate rows and queues no duplicate notifications. A repeat alert is still possible after a crash.
Step 4: push the notification
The notification path depends on your stack. A typical flow.
async def enqueue_notification(filter_id: str, listing: dict): user = await get_user_for_filter(filter_id) beds, baths, sqft = ("?" if listing.get(k) is None else listing[k] for k in ("beds", "baths", "area")) msg = ( f"New listing in {listing.get('addressCity') or 'your area'}: " f"{listing.get('price') or 'price n/a'} • {beds}bd/{baths}ba • " f"{sqft} sqft\n" f"https://www.zillow.com/homedetails/{listing['zpid']}_zpid/" ) await push.send(user.device_token, title="New listing", body=msg) # or: await sendgrid.send_email(user.email, msg) # or: await twilio.send_sms(user.phone, msg)Push, email, SMS, Slack, anything. The shape is the same. The handler queues the work, returns 200 to ZillAPI, and lets a background worker fan out the actual delivery.
Patterns worth knowing
Idempotency. Your webhook handler may be called twice for the same job_id. There is no event id, so use job id plus event as the dedup key in your queue.
Respond fast. ZillAPI expects a 2xx response within a few seconds. Queue the work and return. Do not run the notification path inside the request handler.
Cap per-filter notification frequency. A user with a wide filter (whole metro, no min beds) might get hundreds of new listings in a hot market. Roll them up into a digest if the count exceeds a threshold (say, 10 new in one batch).
Backfill on first run. When a user creates a new filter, the first job will report every match it returns as “new”. Mark all of them as seen without notifying. Notify only on subsequent runs.
Test with a tunnel. While developing, run ngrok http 8000 and register the https ngrok URL with POST /v1/webhooks. ZillAPI will hit it, signature and all. The verification fails fast on bad timestamps, so keep your laptop clock honest.
Rotate the webhook secret without downtime. Register a second webhook and verify against both secrets briefly. Delete the old webhook once you confirm no in-flight retries are still using it.
Track delivery health. Log which jobs delivered, which retried, and which 4xx-failed. Webhooks fail silently if you do not instrument them.
A complete worker in 100 lines
The Python and FastAPI snippets above are the meat. Glue them with a scheduler (cron, apscheduler, a managed cron product), a Postgres or Redis store, and your push provider, and you have a working Zillow listing alert system.
The realistic scaling path. SQLite on a single VM works for the first hundred filters. Postgres on a managed host works to the first few thousand. Redis sets get you past that with cheaper writes. The webhook handler stays the same the whole way.
Tuning the search frequency
Most teams default to 30 minutes and never touch it again. Some use cases want different cadences.
Investor lead-gen products. First-mover advantage is real. 5 to 10 minute cadence on a tight filter (specific zip code, specific price band) is usually worth the extra cost. The credits spent buy you a lead position.
Consumer “homes I would like” alerts. 60 to 120 minutes is fine. Most consumers are not racing other buyers. They want to know about new options, not win a bidding war.
Daily digest products. One scheduled search per day, then the diff goes into an email. Cheap, simple, and reasonable for a lot of “my saved searches” features.
Hot-market overlays. Some teams run a 5-minute cadence in active markets and a 30-minute cadence elsewhere. The dispatch logic looks at the filter’s location and picks the schedule. Worth the complexity once you have hundreds of filters.
The right cadence is the one that is just slightly faster than your competitors’ and just slightly slower than burns your credit balance. Tune to the filter, not the user.
What about new construction or pre-market listings?
This is where Zillow data gets weaker. Pocket listings, off-MLS deals, and pre-market homes do not surface through Zillow’s public listing surface, which means they do not surface through any wrapper either.
If your product needs those, you need a direct MLS feed via Bridge Interactive or a paid pre-MLS data provider. The webhook architecture above does not change. Only the upstream data source does.
Frequently asked questions
Why use webhooks instead of polling for listing alerts?
Webhooks tell your server when a search job finishes, so it does not have to poll for the result. They do not watch Zillow for new listings. Your scheduled searches find those, so an alert is only as fresh as that schedule.
How fast do new Zillow listings show up?
Most MLS data feeds refresh every 5 to 15 minutes depending on the MLS, and Zillow ingests at a similar cadence. A 30-minute scheduled search on your side is a reasonable default. More frequent checks rarely surface new inventory.
How do I verify a ZillAPI webhook signature?
Recompute HMAC-SHA256 over the string formed by concatenating the timestamp, a period, and the raw request body, using your webhook secret as the key. Compare with constant-time comparison against the v1 signature in the X-Zillow-Signature header.
What happens if my webhook endpoint is down when an event fires?
ZillAPI makes 3 attempts in total, then drops the event. To recover, fetch the job with GET /v1/jobs/{id}/results or trigger a backfill search. Handlers that dedupe on job id plus event keep retries safe.
How do I avoid spamming users with old listings on first run?
Backfill on first run. When a user creates a new filter, mark every match in the first webhook as seen without notifying. Notify only on subsequent runs.
Do I need a Postgres database or is something simpler enough?
Anything with a per-filter set of seen zpids works. Postgres, SQLite, Redis sets, or even a JSON file for low-volume cases. You just need durability and atomic upserts for the dedup step.
Monitoring the alert pipeline
A listing alerts product fails silently if you do not instrument it. Users assume “no alerts means no new listings”, which is sometimes true and sometimes a sign your worker has been broken for two days.
Track three numbers per filter. Count of webhook deliveries received per day. Count of new zpids surfaced per day. Count of notifications sent per day.
When the third number drops to zero across all filters, you have a delivery bug. When the second drops to zero on a filter that historically saw new inventory, the filter is now empty (or the search params went stale). When the first drops to zero, the cron is not firing.
A 5-minute Datadog dashboard covers all three. Do not skip this. The first time a paying user emails you to ask why they have not gotten an alert in a week, you will wish you had built it.
Get started
Sign up for ZillAPI, register a webhook, save the secret it returns, and ship. The full protocol details live in Webhooks and the verification recipe in Verify a webhook signature.
Register your handler, run the cron, and you have a real-time Zillow listing alerts system before lunch.
ZillAPI is an independent service and is not affiliated with, endorsed by, or sponsored by Zillow Group, Inc. “Zillow” is a registered trademark of Zillow Group, Inc. Use of those marks on this site is descriptive (nominative fair use). Read our full trademark posture.