-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path01_quickstart.py
More file actions
30 lines (25 loc) · 905 Bytes
/
01_quickstart.py
File metadata and controls
30 lines (25 loc) · 905 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
"""Quickstart: look up one property and print the Zestimate.
Run:
pip install -r requirements.txt
export ZILLAPI_KEY="zk_..."
python 01_quickstart.py
"""
import os
import httpx
KEY = os.environ["ZILLAPI_KEY"]
ADDRESS = "1600 Pennsylvania Ave NW, Washington DC 20500"
resp = httpx.get(
"https://api.zillapi.com/v1/properties/by-address",
params={"address": ADDRESS},
headers={"Authorization": f"Bearer {KEY}"},
timeout=30,
)
resp.raise_for_status()
prop = resp.json()["data"]
addr = prop["address"]
print(f"{addr['streetAddress']}, {addr['city']}, {addr['state']} {addr['zipcode']}")
print(f"zpid: {prop['zpid']}")
print(f"Zestimate: ${prop['zestimate']:,}" if prop.get("zestimate") else "Zestimate: n/a")
print(f"Beds/baths: {prop['bedrooms']}/{prop['bathrooms']}")
print(f"Living area: {prop['livingArea']:,} sqft")
print(f"Year built: {prop['yearBuilt']}")