This Flask API allows users to search for properties near a misspelled city name using spell correction and geolocation. It supports fuzzy matching of Indian city names and returns a list of nearby properties within a 50km radius.
- ✅ Corrects misspelled Indian city names using
pyspellchecker - ✅ Uses the
IndiaCities.csvas the city database - ✅ Geocodes corrected city names using the
geopyNominatim API - ✅ Filters nearby properties within a 50 km radius
- ✅ Returns property names with distance in kilometers
Install all dependencies using pip:
pip install flask geopy pyspellcheckerproject/
│
├── app.py # Main Flask application
├── IndiaCities.csv # Database of Indian city names
└── README.md # This file
- Ensure Python is installed.
- Clone/download this project.
- Run the Flask server:
python app.pyThe API will be available at:
http://127.0.0.1:5000/api/properties
GET /api/properties?query=<city_name>
| Parameter | Type | Description |
|---|---|---|
query |
string | Misspelled or correct city name |
curl "http://127.0.0.1:5000/api/properties?query=delih"{
"properties": [
{
"property": "Moustache Delhi",
"distance_km": 3.75
}
]
}If no properties are found:
{
"message": "No properties available"
}- The city name is spell-checked using the
pyspellcheckerlibrary. - It uses city names from
IndiaCities.csvto correct possible errors. - Once corrected, it is geocoded using the Nominatim API.
- Then we calculate the distance of this location from a list of predefined properties.
- Properties within 50 km are returned.
| Input | Corrected |
|---|---|
delih |
delhi |
bangalre |
bangalore |
mumbay |
mumbai |
- Add support for multiple countries or global city lists.
- Use caching for repeated geocode queries.
- Add confidence level for spelling corrections.
For questions or support, feel free to reach out to Swagat Nayak