A simple FastAPI project that exposes housing data from a private database through an API endpoint.
This project was created for learning purposes and was designed to provide data for a real-time housing dashboard.
The API demonstrates how to:
- Connect a FastAPI application to a database
- Query housing listings
- Filter data by city, date, and price
- Expose database data through a REST endpoint
This project cannot be run completely without access to the private database and its connection string.
The database connection is configured with the URL_CONN environment variable:
URL_CONN=your_database_connection_stringInstall the dependencies:
pip install -r requirements.txtStart the server:
uvicorn main:app --reload --port 8001Open the API documentation:
http://127.0.0.1:8001/docs
GET /housing
Example:
/housing?city=Rabat&price_min=1000000&price_max=5000000
Supported cities:
- Rabat
- Tanger
- Casablanca
The API expects a database table named:
housing_listings
The project is intended for learning and demonstration purposes.