Skip to content

REST API

Tomas Stenlund edited this page Feb 3, 2020 · 4 revisions

REST API and Portal endpoint documentation

The single page web application is located at /index.html.

The REST interface is located at /api. You need to authenticate first to get a token than must be provided when using the other endpoints in the API. The following headers must be set:

Authorization: Bearer <token>
Content-Type: application/json
Accept: application/json

Value representations

All keys in the URL, request or response bodies are 64 bit integers written as a string of 16 hex characters, i.e. 0123456789ABCDEF.

All dates are UTC timestamp represented as a string of date and time with a zero offset time zone designator Z, i.e. 2020-11-23T13:25:26.273041154Z.

Authenticate - POST /api/authenticate

Authenticates a user using the provided username and password and returns a token to be used for all the other endpoints in the API.

POST /api/authenticate
{ "username":"<username>",
"password":"<password>"}

The response body contains:

{"username":"<username>",
"email": "<emailaddress>,
"token": "<token>",
"userid": "<user key>"}

Where the token is to be used for the authorization header.

Fetch an item - GET /api/item/<item key>

Returns with the geographical item as JSON.

Update an item - PUT /api/item/<item_key>

The PUT body contains the fields on the item that is to be updated. The item_key points to the item.

Create an item - POST /api/item

The POST body contains the item as JSON and the item is returned with the item_key added.

Fetch a list of items - POST /api/items

The POST body contains the selection filters and a list of items returned as JSON.