Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

1.7 KB
Raw Blame
from dataclasses import dataclass, field

from products.warehouse_sources.sources.sdk import IncrementalField


@dataclass(frozen=False)
class RentCastEndpointConfig:
    name: str
    path: str
    # RentCast assigns each property and listing a stable, globally unique `id`, so it is a safe
    # primary key across full-refresh syncs.
    primary_keys: list[str] = field(default_factory=lambda: ["id"])


# RentCast v1 list endpoints. All are full-refresh only: RentCast exposes no server-side
# updated-since cursor (listing search only filters by `daysOld`, days since first listed, which
# isn't a last-modified timestamp), so there is no incremental cursor to advance safely.
#
# The search endpoints return a record list via limit/offset pagination. RentCast is a
# property-lookup API, so they accept optional geographic filters (city/state/zipCode/lat-long) and
# fall back to a broad default area when none is supplied.
#
# `/markets` returns one aggregate object per call and requires a `zipCode`, so the `markets` table
# makes one request per ZIP code the user lists in the source settings. The response `id` is the ZIP
# code itself.
MARKETS_ENDPOINT = "markets"

RENTCAST_ENDPOINTS: dict[str, RentCastEndpointConfig] = {
    "properties": RentCastEndpointConfig(name="properties", path="/properties"),
    "sale_listings": RentCastEndpointConfig(name="sale_listings", path="/listings/sale"),
    "rental_listings": RentCastEndpointConfig(name="rental_listings", path="/listings/rental/long-term"),
    MARKETS_ENDPOINT: RentCastEndpointConfig(name=MARKETS_ENDPOINT, path="/markets"),
}

ENDPOINTS = tuple(RENTCAST_ENDPOINTS.keys())

INCREMENTAL_FIELDS: dict[str, list[IncrementalField]] = {}