API Template usage cheatsheet: Difference between revisions
Jump to navigation
Jump to search
mNo edit summary |
mNo edit summary |
||
(9 intermediate revisions by the same user not shown) | |||
Line 33: | Line 33: | ||
|table= | |table= | ||
{{{!}} | {{{!}} | ||
! | ! !! URL !! Parameters !! Response | ||
{{!}}- | {{!}}- | ||
{{!}} POST {{!}}{{!}} /api/io/start/ | {{!}} POST {{!}}{{!}} /api/io/start/ {{!}}{{!}} ["EDITOR", "demo_heat_stress"] {{!}}{{!}} sessionId | ||
{{!}}- | {{!}}- | ||
{{!}} POST {{!}}{{!}} /api/io/save_project_as/ | {{!}} POST {{!}}{{!}} /api/io/save_project_as/ {{!}}{{!}} [''sessionId'', "","my_project",false] {{!}}{{!}} Whether succesful | ||
{{!}}- | {{!}}- | ||
{{!}} POST {{!}}{{!}} /api/io/join/ | {{!}} POST {{!}}{{!}} /api/io/join/ {{!}}{{!}} [''sessionId'', "EDITOR"] {{!}}{{!}} json, including apiToken | ||
{{!}}} | {{!}}} | ||
}} | }} | ||
Line 50: | Line 50: | ||
|table= | |table= | ||
{{{!}} | {{{!}} | ||
! | ! !! URL !! Parameters !! Response | ||
{{!}}- | {{!}}- | ||
{{!}} POST {{!}}{{!}} api/session/event/editor/clear_map/ | {{!}} POST {{!}}{{!}} api/session/event/editor/clear_map/ {{!}}{{!}} [true] {{!}}{{!}} n/a | ||
{{!}}- | {{!}}- | ||
{{!}} POST {{!}}{{!}} /api/session/event/editor/set_initial_map_size/ | {{!}} POST {{!}}{{!}} /api/session/event/editor/set_initial_map_size/ {{!}}{{!}} [2000,2000] {{!}}{{!}} n/a | ||
{{!}}- | {{!}}- | ||
{{!}} POST {{!}}{{!}} api/session/event/editor/start_map_creation? | {{!}} POST {{!}}{{!}} api/session/event/editor/start_map_creation?crs=4326 {{!}}{{!}} [4.312135, 52.080617, null, []] {{!}}{{!}} n/a | ||
{{!}}- | {{!}}- | ||
{{!}} GET {{!}}{{!}} /api/session/info/ | {{!}} GET {{!}}{{!}} /api/session/info/ {{!}}{{!}} {{!}}{{!}} json, including state.<br> "NORMAL" means<br>generation is done | ||
{{!}}} | {{!}}} | ||
}} | }} | ||
{{cheatsheet-block | |||
|title=Get results | |||
|type=results | |||
|text= | |||
|image= | |||
|table= | |||
{{{!}} | |||
! Data !! Calculation | |||
{{!}}- | |||
{{!}} | |||
* /api/session/wfs/ | |||
* /api/session/items/neighborhoods?f=GEOJSON | |||
* /api/session/items/areas?f=GEOJSON | |||
{{!}}{{!}} | |||
* /web/wms/ | |||
* /api/session/overlay.png?id=''overlayId'' | |||
* /api/session/overlay.geotiff?id=''overlayId'' | |||
* /web/indicator.html?id=''indicatorId'' | |||
{{!}}} | |||
}} | |||
{{cheatsheet-block | {{cheatsheet-block | ||
|title=Notes | |title=Notes | ||
Line 66: | Line 88: | ||
|image= | |image= | ||
|text=<nowiki></nowiki> | |text=<nowiki></nowiki> | ||
* Unless otherwise specified, calls should be accompanied with a query parameter "&f=JSON", to define JSON as the used datastructure in data and responses. | |||
* 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]]. | * 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: | * All coordinates are x:y, or longitude:latitude. 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. | * To add an Area of Interest, in the "start_map_creation" event replace the empty array with an array of MultiPolygons. | ||
}} | }} | ||
}} | }} |
Latest revision as of 06:41, 3 April 2025
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:
URL | Parameters | Response | |
---|---|---|---|
POST | /api/io/start/ | ["EDITOR", "demo_heat_stress"] | sessionId |
POST | /api/io/save_project_as/ | [sessionId, "","my_project",false] | Whether succesful |
POST | /api/io/join/ | [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 ):
URL | Parameters | Response | |
---|---|---|---|
POST | api/session/event/editor/clear_map/ | [true] | n/a |
POST | /api/session/event/editor/set_initial_map_size/ | [2000,2000] | n/a |
POST | api/session/event/editor/start_map_creation?crs=4326 | [4.312135, 52.080617, null, []] | n/a |
GET | /api/session/info/ | json, including state. "NORMAL" means generation is done |
Get results
Data | Calculation |
---|---|
|
|
Notes
- Unless otherwise specified, calls should be accompanied with a query parameter "&f=JSON", to define JSON as the used datastructure in data and responses.
- 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:latitude. 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.