DEV Community

Zachary Hampton
Zachary Hampton

Posted on AI-assisted

Get sold home prices in Python in 5 lines

Asking prices are easy to find. Sold prices are harder. This post gets every home sold in Phoenix last month, with its price, in five lines of Python. It's free, with no API key.

We'll use HomeHarvest, an open source library I maintain. It has 767 GitHub stars and about 35,000 PyPI downloads a month. It reads public US property data and hands you a pandas table.

Step 1: install

You need Python 3.11 or newer. New to Python? Get it from python.org first.

pip install -U homeharvest
Enter fullscreen mode Exit fullscreen mode

Step 2: the five lines

from homeharvest import scrape_property

homes = scrape_property(location="Phoenix, AZ", listing_type="sold", past_days=30)
print(len(homes))
print(homes[["sold_price", "last_sold_date", "beds", "full_baths", "sqft", "zip_code"]].head())
print(homes["sold_price"].median())
Enter fullscreen mode Exit fullscreen mode

Output (real run on 2.1.0, 2026-12-01, a few seconds):

1093
   sold_price       last_sold_date beds full_baths  sqft zip_code
0      414000  2026-12-01 09:11:13    3          2  1272    85008
1      349900  2026-11-30 00:00:00    2          2  1097    85022
2      363900  2026-11-30 00:00:00    3          2  1488    85041
3      500000  2026-11-30 00:00:00    5          3  2688    85353
4     1300000  2026-11-30 00:00:00    6          5  3157    85018
450000.0
Enter fullscreen mode Exit fullscreen mode

That's 1,093 homes sold in Phoenix in 30 days, with a median of $450,000. Not every row is full: 185 had no beds and 68 had no sqft. We'll handle that below.

Step 3: comps around one home

Give it an address and a radius in miles. You get the sales nearby.

comps = scrape_property(location="1 E Washington St, Phoenix, AZ 85004",
                        listing_type="sold", radius=1.0, past_days=180)
print(len(comps), comps["sold_price"].median())
Enter fullscreen mode Exit fullscreen mode

My run gave 41 sales within a mile in 6 months. The median was $387,000. Each had a price.

Step 4: price per square foot by zip code

priced = homes.dropna(subset=["sold_price", "sqft"])
priced = priced[priced["sqft"] > 0]   # skip homes listed at 0 sqft
priced = priced.assign(ppsf=(priced["sold_price"] / priced["sqft"]).astype(float))
print(priced.groupby("zip_code")["ppsf"].median().sort_values().tail(5))
Enter fullscreen mode Exit fullscreen mode

A zip code with only a few sales can swing a lot. Check how many sales each one has before you trust it.

Step 5: save it

homes.to_csv("phoenix_sold.csv", index=False)
Enter fullscreen mode Exit fullscreen mode

What to watch for

Some states keep sale prices private. Texas is one. Run Austin and you get 558 sales with no price on any of them. Check how full the column is before you trust a median:

homes["sold_price"].notna().mean()
Enter fullscreen mode Exit fullscreen mode

This is public listing data, not an MLS feed. Use it for research and your own tools. Don't resell it.

What else it does

Swap "sold" for "for_sale", "pending" or "for_rent". For sale rows include the listing agent's name and email, and the listing text.

Add extra_property_data=True for schools, tax records, past sales, the buyer's agent and nearby rent. It's slower: the Phoenix search took 37 seconds instead of 4.

Since 2.1, the same call runs in a Cloudflare Python Worker. The free open house list on homeharvestdata.com runs that way. There's also an MCP server, so Claude or another AI tool can ask for this data in SQL.

Code: github.com/ZacharyHampton/HomeHarvest
Docs: homeharvestdata.com

Top comments (0)