REST
Run a RESTful API¶
Setup & run¶
Install requirements¶
cd python/restapi/ && pip install -r requirements.txt
Setup DB connection¶
Set the database connection string as an environment variable:
export UNDERPASS_API_DB=postgresql://localhost/underpass
Run¶
uvicorn main:app --reload
Making queries¶
Raw data¶
Get polygons¶
curl http://localhost:8000/raw/polygons -X POST \
-H 'content-type: application/json' \
--data-raw '{"area":"-180 90,180 90, 180 -90, -180 -90,-180 90", "tags": "building=yes"}'
Get lines¶
curl http://localhost:8000/raw/lines -X POST \
-H 'content-type: application/json' \
--data-raw '{"area":"-180 90,180 90, 180 -90, -180 -90,-180 90", "tags": "highway"}'
Get nodes¶
curl http://localhost:8000/raw/nodes -X POST \
-H 'content-type: application/json' \
--data-raw '{"area":"-180 90,180 90, 180 -90, -180 -90,-180 90", "tags": "amenity"}'
Get all together (polygons, lines and nodes)¶
curl http://localhost:8000/raw/all -X POST \
-H 'content-type: application/json' \
--data-raw '{"area":"-180 90,180 90, 180 -90, -180 -90,-180 90", "tags": "building"}'
Get list of polygons¶
curl http://localhost:8000/raw/polygonsList -X POST \
-H 'content-type: application/json' \
--data-raw '{"area":"-180 90,180 90, 180 -90, -180 -90,-180 90", "tags": "building=yes"}'
Get list of lines¶
curl http://localhost:8000/raw/linesList -X POST \
-H 'content-type: application/json' \
--data-raw '{"area":"-180 90,180 90, 180 -90, -180 -90,-180 90", "tags": "highway"}'
Get list of nodes¶
curl http://localhost:8000/raw/nodesList -X POST \
-H 'content-type: application/json' \
--data-raw '{"area":"-180 90,180 90, 180 -90, -180 -90,-180 90", "tags": "amenity"}'
Get list of all together (polygons, lines and nodes)¶
curl http://localhost:8000/raw/allList -X POST \
-H 'content-type: application/json' \
--data-raw '{"area":"-180 90,180 90, 180 -90, -180 -90,-180 90", "tags": "building"}'
Get data quality reports in CSV or GeoJSON¶
Get report for geometries¶
curl http://localhost:8000/report/dataQualityGeo -X POST \
-H 'content-type: application/json' \
--data-raw '{"fromDate":"2022-12-28T00:00:00", "hashtags": "hotosm"}'
In CSV format instead of GeoJSON:
curl http://localhost:8000/report/dataQualityGeo/csv -X POST \
-H 'content-type: application/json' \
--data-raw '{"fromDate":"2022-12-28T00:00:00", "hashtags": "hotosm"}'
Get report for tags¶
curl http://localhost:8000/report/dataQualityTags -X POST \
-H 'content-type: application/json' \
--data-raw '{"fromDate":"2022-12-28T00:00:00", "hashtags": "hotosm"}'
Get statistics for tags¶
curl http://localhost:8000/report/dataQualityTagStats -X POST \
-H 'content-type: application/json' \
--data-raw '{"fromDate":"2022-12-28T00:00:00", "hashtags": "hotosm"}'