A rental yield calculator is one of the highest-value tools an investor can have. This tutorial builds a simple but functional version in Python + HTML that fetches live data for any ZIP code.

Backend: Python FastAPI Proxy

from fastapi import FastAPI import httpx, os app = FastAPI() KEY = os.environ["ZIPMARKET_KEY"] @app.get("/yield/{zip_code}") async def yield_calc(zip_code: str, bedrooms: int = 2): async with httpx.AsyncClient() as client: r = await client.get( "https://zipmarketdata.com/rental-yield", params={"zip_code": zip_code, "bedrooms": bedrooms}, headers={"x-rapidapi-proxy-secret": KEY} ) data = r.json() # Compute net yield estimate data["estimated_net_yield_pct"] = round(data["gross_yield_pct"] * 0.65, 2) return data

Frontend: Yield Display

async function fetchYield(zip, br) { const data = await fetch(`/yield/${zip}?bedrooms=${br}`).then(r => r.json()); document.getElementById('gross').textContent = `${data.gross_yield_pct}%`; document.getElementById('net').textContent = `${data.estimated_net_yield_pct}%`; document.getElementById('rent').textContent = `$${data.fair_market_rent}/mo`; document.getElementById('price').textContent = `$${data.median_sale_price.toLocaleString()}`; }

Adding Mortgage Sensitivity

Extend the backend to accept a down_payment_pct parameter and calculate CoC return at different leverage levels. Pair with the /property-estimate endpoint which handles this automatically for quick prototyping.