A FastAPI-based REST API that serves home price predictions for State College, PA.
- Historical Data: Access 20+ years of Zillow Home Value Index (ZHVI) data
- Future Predictions: Get model predictions through 2031
- Interactive Queries: Query specific dates for price predictions
- Chart Data: Formatted data for visualization
Returns basic API information.
Returns all historical and predicted price data.
Response:
[
{
"date": "2005-07",
"price": 160901.18,
"type": "historical"
},
{
"date": "2026-02",
"price": 335002.45,
"type": "predicted"
}
]Returns prediction for a specific year and month.
Parameters:
year: Integer (2005-2031)month: Integer (1-12)
Response:
{
"date": "2026-03",
"price": 335002.45,
"type": "predicted"
}Returns the available date range.
Response:
{
"min_date": "2005-07",
"max_date": "2031-01",
"total_records": 307
}Returns data formatted for chart visualization.
Response:
{
"historical": [...],
"predicted": [...],
"all": [...]
}- Navigate to the API directory:
cd api- Install dependencies:
pip install -r requirements.txt- Run the API server:
uvicorn main:app --reload --host 0.0.0.0 --port 8000The API will be available at http://localhost:8000
The API is designed to work with the price_predictor.html frontend. Make sure:
- The API server is running on
http://localhost:8000 - The HTML file can access the API (CORS is enabled)
- Update the
API_BASE_URLin the HTML file if needed
- Historical Data: Zillow Home Value Index (ZHVI) CSV file
- Predictions: Machine learning model predictions (Random Forest, 99.98% R²)
The API returns appropriate HTTP status codes:
200: Success404: No data found for requested date500: Server error
CORS is enabled to allow the HTML frontend to make requests from any origin.