A geospatial REST API and web interface for country boundary data.
git clone https://github.com/PriyanshBordia/Spatial-Data-using-FastAPI.git
cd Spatial-Data-using-FastAPI
docker compose up -d --buildSeed the database:
GET http://localhost:8002/populate_data
export DB_NAME=spatial_data
export DB_USERNAME=postgres
export DB_PASSWORD=postgres
export DB_HOST=localhost
export DB_PORT=5432
export API_KEY="" # Set to enable auth on write endpointsGET / # Health check
GET /populate_data # Seed database
GET /country/id/{id} # By ID
GET /country/code/{code} # By ISO A3 code (case-insensitive)
GET /country/name/{name} # By exact name
GET /country/name/contains/{fragment} # Search by name
GET /countries?skip=0&limit=100 # Paginated list
GET /country/neighbors/{id} # Bordering countries
POST /country/create/ # Create country
PUT /country/update/{id} # Update country
DELETE /country/delete/{id} # Delete country
GET /web # 3D globe — click countries to explore
GET /web/country/add # Add country form
POST /web/country/add # Submit new country
GET /web/upload # Upload form
POST /web/upload # Bulk upload GeoJSON
All pages support dark mode (toggle in bottom-left corner, persists via localStorage).
{
"admin": "Wakanda",
"iso_a3": "WKA",
"geom": {
"type": "Polygon",
"coordinates": [[[30, -1], [30, 1], [32, 1], [32, -1], [30, -1]]]
}
}Polygon geometries are automatically promoted to MultiPolygon.
{
"success": true,
"message": "API is fast..",
"meta": { "size": 1 },
"result": [
{
"id": 1,
"name": "India",
"code": "IND",
"coordinates": [...]
}
]
}{
"success": false,
"error": {
"message": ["Country with id: 0 does not exist."]
}
}docker compose exec fastapi python3 -m pytest app/tests/ -v38 integration tests using real PostGIS seed data.