> ## Documentation Index
> Fetch the complete documentation index at: https://docs.trassets.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Incrementally sync real-estate data with Trassets

> Fetch only changed data using offset pagination and category endpoints to keep a local copy of Trassets data up to date without re-fetching everything.

Use the Trassets Data API category endpoints to maintain a continuously updated local copy of your data without transferring every row on each run. Offset-based pagination provides predictable resumption points across scheduled syncs.

<Steps>
  <Step title="Fetch the first page">
    Start with `limit=1000` and `offset=0`. The example uses the `/property/properties` endpoint, but the pattern works for any category endpoint.

    ```bash theme={null}
    curl -s "https://api.trassets.ai/property/properties?limit=1000&offset=0" \
      -H "X-API-Key: $TRASSETS_API_KEY"
    ```
  </Step>

  <Step title="Check the pagination headers">
    Inspect the response headers after each request:

    * `X-Has-More`: `"true"` if additional pages exist
    * `X-Next-Offset`: the offset to use for the next page (present only when `X-Has-More` is `"true"`)
    * `X-Total-Count`: total rows available for the current query

    If `X-Has-More` is `"true"`, increment the offset by your limit and repeat until you reach the end.
  </Step>

  <Step title="Store the next offset for the next run">
    Persist the value of `X-Next-Offset` from the last successful request. On the next scheduled sync, start from this stored offset instead of zero to avoid re-fetching rows you already have.

    For example, if the previous run ended at offset `4000`, your next run begins with:

    ```bash theme={null}
    curl -s "https://api.trassets.ai/property/properties?limit=1000&offset=4000" \
      -H "X-API-Key: $TRASSETS_API_KEY"
    ```
  </Step>

  <Step title="Reset when the data changes significantly">
    If you detect a schema change, a full reload requirement, or a large gap between syncs, reset your stored offset to `0` and pull the full dataset again.
  </Step>

  <Step title="Full Python example">
    A complete script that fetches every page, resuming from a stored offset. Requires the [`requests`](https://pypi.org/project/requests/) package.

    ```python sync_properties.py theme={null}
    import os
    import requests

    API_KEY = os.environ["TRASSETS_API_KEY"]
    BASE_URL = "https://api.trassets.ai"
    HEADERS = {"X-API-Key": API_KEY}


    def sync_properties(start_offset: int = 0, page_size: int = 1000) -> list[dict]:
        """Fetch all rows from /property/properties starting at start_offset.

        Returns the combined rows and the offset to resume from on the next run.
        """
        rows: list[dict] = []
        offset = start_offset

        while True:
            resp = requests.get(
                f"{BASE_URL}/property/properties",
                headers=HEADERS,
                params={"limit": page_size, "offset": offset},
                timeout=30,
            )
            resp.raise_for_status()
            rows.extend(resp.json())

            has_more = resp.headers.get("X-Has-More") == "true"
            if not has_more:
                break
            offset = int(resp.headers["X-Next-Offset"])

        return rows, offset


    if __name__ == "__main__":
        # On the next scheduled run, pass the returned offset back in as
        # start_offset instead of 0 to avoid re-fetching rows you already have.
        rows, next_offset = sync_properties(start_offset=0)
        print(f"Fetched {len(rows)} rows, resume offset: {next_offset}")
    ```
  </Step>
</Steps>

<Tip>
  Before running a full incremental fetch, check the [`/changes`](/guides/delta-sync) endpoint to discover which tables have been updated since your last sync. Skip any tables that have not changed to save requests and stay within the 500 req/h rate limit.
</Tip>
