This section is a curated collection of ready-to-use code examples, helper functions, utilities to accelerate your work with our Property Data API. You’ll find snippets for data normalization, such as unit number formatting and address standardization, authentication flows, pagination handling, error handling routines, and response parsing. Each sample includes clear usage notes and parameter details so you can drop it straight into your project and get up and running faster.

Unit Number Normalization (Python)

This Python utility cleans raw unit information by removing common designators such as apartment, basement, suite, and their abbreviations in a case-insensitive way. It dynamically builds a regular expression from a mapping of full words and abbreviations, strips out any matches, then trims whitespace to return only the core unit identifier.

normalize_unit_number.py
import re

unit_designators_mapping = {
    "APARTMENT": "APT",
    "BASEMENT": "BSMT",
    "BUILDING": "BLDG",
    "DEPARTMENT": "DEPT",
    "FLOOR": "FL",
    "FRONT": "FRNT",
    "HANGER": "HNGR",
    "KEY": "KEY",
    "LOBBY": "LBBY",
    "LOT": "LOT",
    "LOWER": "LOWR",
    "OFFICE": "OFC",
    "PENTHOUSE": "PH",
    "PIER": "PIER",
    "REAR": "REAR",
    "ROOM": "RM",
    "SIDE": "SIDE",
    "SLIP": "SLIP",
    "SPACE": "SPC",
    "STOP": "STOP",
    "SUITE": "STE",
    "TRAILER": "TRLR",
    "UNIT": "UNIT",
    "UPPER": "UPPR",
    "#": "NUMBER"
}

# build sets of all designators (full words and abbreviations)
all_designators = set(unit_designators_mapping.keys()) | set(unit_designators_mapping.values())

# split into word-only vs symbol-containing
word_designators = [d for d in all_designators if re.match(r'^\w+$', d)]
symbol_designators = [d for d in all_designators if not re.match(r'^\w+$', d)]

# build two sub-patterns: one with \b…\b for word-designators, one raw for symbols
parts = []
if word_designators:
    parts.append(r"\b(?:" + "|".join(re.escape(d) for d in word_designators) + r")\b")
if symbol_designators:
    parts.append("|".join(re.escape(d) for d in symbol_designators))

# final pattern matches either case
unit_identifiers = r"(?:" + "|".join(parts) + r")"

def normalize_unit_number(unit_info: str) -> str:
    """
    Remove known designators (case-insensitive), then trim whitespace.
    """
    return re.sub(unit_identifiers, "", unit_info, flags=re.IGNORECASE).strip()

# example usage
if __name__ == "__main__":
    print(normalize_unit_number("Apartment 12B"))   # "12B"
    print(normalize_unit_number("#300"))           # "300"
    print(normalize_unit_number("# 300"))          # "300"
    print(normalize_unit_number("number 300"))     # "300"
    print(normalize_unit_number("Unit 12A"))       # "12A"
    print(normalize_unit_number("Suite 100"))      # "100"
    print(normalize_unit_number("Apt 5"))          # "5"
    print(normalize_unit_number("BSMT 1"))         # "1"
    print(normalize_unit_number("FL 3"))           # "3"
    print(normalize_unit_number("PH 2"))           # "2"
    print(normalize_unit_number("TRLR 4"))         # "4"
    print(normalize_unit_number("123"))            # "123" (no change)
    print(normalize_unit_number("  "))             # "" (empty string)

Pagination Example (Python)

Below is an example script demonstrating how to paginate through property search results for Monterey County using limit and offset, printing each batch until no more results are returned.

pagination_monterey.py
import requests

# Set the request headers with your API Key
headers = {"Authorization": "<YOUR_API_KEY>"}

# Define the API endpoint URL
url = "https://app.realie.ai/api/public/property/search/"

# Set the number of records to fetch per request (limit) and initialize the offset
limit = 10
offset = 0

while True:
    # Define query parameters including limit, offset, county, and state
    params = {"limit": limit, "offset": offset, "county": "MONTEREY", "state": "CA"}
    
    # Send a GET request to the API with the headers and parameters
    response = requests.get(url, headers=headers, params=params)
    
    # Check if the response returned a non-200 status code
    if response.status_code != 200:
        print("Error:", response.status_code, response.text)
        break

    # Parse the JSON response and extract the list of properties
    properties = response.json().get("properties", [])
    
    # Print the current offset and how many properties were fetched
    print(f"Offset: {offset} | Fetched {len(properties)} properties")
    
    # If no properties are returned, exit the loop
    if not properties:
        break

    # Loop through each property and print its details
    for prop in properties:
        print(prop)

    # Increase the offset by the limit to fetch the next batch
    offset += limit

# Print a final message after finishing the loop
print("Finished looping through parcels.")