This tutorial walks through a complete Python workflow: fetching market stats for a list of ZIP codes, parsing the JSON responses, and building a simple screening table sorted by investment attractiveness.

Requirements

pip install requests pandas

Fetching a Single ZIP Code

import requests API_KEY = "your_rapidapi_key" BASE_URL = "https://zipmarketdata.com" def get_market_stats(zip_code): resp = requests.get( f"{BASE_URL}/market-stats", params={"zip_code": zip_code}, headers={"x-rapidapi-proxy-secret": API_KEY}, timeout=10 ) resp.raise_for_status() return resp.json() data = get_market_stats("78701") print(f"Median price: ${data['median_sale_price']:,}") print(f"DOM: {data['median_days_on_market']} days") print(f"Temperature: {data['market_temperature']}")

Bulk Screening Across Multiple ZIPs

import pandas as pd import time TARGET_ZIPS = ["78701", "30301", "85001", "37201", "97201"] rows = [] for zip_code in TARGET_ZIPS: try: d = get_market_stats(zip_code) rows.append(d) time.sleep(0.5) # stay within rate limits except Exception as e: print(f"Error for {zip_code}: {e}") df = pd.DataFrame(rows) df_sorted = df.sort_values("yoy_price_change", ascending=False) print(df_sorted[["zip_code","median_sale_price","median_days_on_market", "yoy_price_change","market_temperature"]])

Adding Rental Yield Data

def get_rental_yield(zip_code, bedrooms=2): resp = requests.get( f"{BASE_URL}/rental-yield", params={"zip_code": zip_code, "bedrooms": bedrooms}, headers={"x-rapidapi-proxy-secret": API_KEY}, timeout=10 ) resp.raise_for_status() return resp.json() # Merge with market stats DataFrame yields = [get_rental_yield(z) for z in TARGET_ZIPS] df_yield = pd.DataFrame(yields)[["zip_code", "gross_yield_pct", "fair_market_rent"]] df_final = df.merge(df_yield, on="zip_code") print(df_final.sort_values("gross_yield_pct", ascending=False))