API Template usage cheatsheet
Authentication
Every API call must be accompanied with an appropriate form of authentication
URL starts with | Description | Example |
---|---|---|
/api/ | HTTP Basic Authentication Header | "Authorization: Basic "+b64en("user@example.com:password") |
/api/session/ | API token query parameter | "/api/session/items/neighborhoods?f=JSON&token=[...]" |
/web/ | Web (or API) token query parameter | "/api/web/2dmap.html?f=JSON&token=[...]" |
Applying a Template project
Use "demo heat stress" to create a new Project named "my_project", and get its API Token for further access:
Method | Parameters | Response | |
---|---|---|---|
POST | /api/io/start/?f=JSON | ["EDITOR", "demo_heat_stress"] | sessionId |
POST | /api/io/save_project_as/?f=JSON | [sessionId, "","my_project",false] | Whether succesful |
POST | /api/io/join/?f=JSON | [sessionId, "EDITOR"] | json, including apiToken |
Generate on new location
Set new Project to a 2km by km map size, and its location to latitude 52.080617, longitude 4.312135 (in coordinate system EPSG:4326 ):
Method | URL | Parameters | Response |
---|---|---|---|
POST | api/session/event/editor/clear_map/?f=JSON | [true] | n/a |
POST | /api/session/event/editor/set_initial_map_size/?f=JSON | [2000,2000] | n/a |
POST | api/session/event/editor/start_map_creation?f=JSON&crs=4326 | [52.080617, 4.312135, false, []] | n/a |
GET | /api/session/info/?f=JSON | json, including state. "NORMAL" means generation is done |
Notes
- Any Project can be used as a Template, as long as there is no currently running Session, or the Project is set to read-only.
- All coordinates are x:y, or longitude:latitute. This also includes coordinates in MultiPolygons.
- To add an Area of Interest, in the "start_map_creation" event replace the empty array with an array of MultiPolygons.