Skip to content

API Reference

Sematre edited this page May 25, 2021 · 48 revisions

General

It's madatory to provide the following http headers in every request (unless stated otherwise):

  • Content-Type: application/json
  • Accept: application/json

You most likely need to include the X-StoRe-Session: abcd1234 header for restricted content.

If you don't provide a session id and try to access restricted content the server responds the this with an 401 (Unauthorized) status code (unless stated otherwise).

Error 403 occurs (general speaking) if you try to access restricted content and don't have the right permissions to do so or the session id is simply invalid/expired.

The server responses with the status code 400 (Bad Request) if the client sends unparsable data e.g. an invalid json body.

Unknown request methods result in server error code 501 (Not Implemented).

Authentication

[GET | POST] /api/v1/auth

Create a new session

Request

{
"username": "foo",
"password": "bar"
}

Response

StatusDescription
200 SuccessYour login request was successful.
The session id always contains 8 lower case alphanumeric characters (a-z + 0-9).
{"session_id": "abcd1234"}
403 Login FailedYour username or password was incorrect.

DELETE /api/v1/auth

Delete a session (logging out)

The server takes the session provided by the client in the X-StoRe-Session http header and destroys it.

Response

StatusDescription
200 SuccessYou're now logged out.

Items

GET /api/v1/items

Get a list of all the items

Request

If-Modified-Since (optional)

To save some bandwidth you can specify this HTTP header to only send an http body when it's actually necessary.

Response

StatusDescription
200 SuccessThe HTTP header Last-Modified contains the date of the most recent modification to an item.

Json array of Items
204 No ContentNo items are stored.
304 Not ModifiedNo changes since the specified date.

GET /api/v1/item/<item_id>

Get the specified item

Request

If-Modified-Since (optional)

To save some bandwidth you can specify this HTTP header to only send an http body when it's actually necessary.

Response

StatusDescription
200 SuccessThe HTTP header Last-Modified contains the date of the last modification to the item.

The body contains your specified Item.
304 Not ModifiedNo changes since the specified date.
404 Not FoundThe specified item couldn't be found.

PUT /api/v1/item

Create a new item

Request

Item datatype without item_id field.

Response

StatusDescription
201 Created{"item_id": <item_id>}
404 Not FoundThe request contained invalid data.
e.g. an unknown tag id

UPDATE /api/v1/item/<item_id>

Update an existing item

Request

Item datatype without item_id field.

If-Unmodified-Since (optional)

If you wish to only update the item if it hasn't been modified. Otherwise the server will forcefully overwrite the item.

Response

StatusDescription
200 SuccessThe item has been updated.
409 ConflictThe item has been updated since the specified date.
404 Not FoundThe request contained invalid data.
e.g. an unknown tag id

DELETE /api/v1/item/<item_id>

Delete the specified item

Response

StatusDescription
200 SuccessThe item has been deleted.
404 Not FoundThe specified item couldn't be found.
409 ConflictThere is an item that depends on this tag.

Tags

GET /api/v1/tags

Get a list of all tags

Response

StatusDescription
200 SuccessJson array of Tags
204 No ContentNo tags are defined.

PUT /api/v1/tag

Create a new tag

Request

Tag datatype without tag_id field.

Response

StatusDescription
201 Created{"tag_id": <tag_id>}

UPDATE /api/v1/tag/<tag_id>

Update an existing tag

Request

Tag datatype without tag_id field.

Response

StatusDescription
200 SuccessThe tag has been updated.
404 Not FoundThe specified tag couldn't be found.
409 ConflictThis tag name already exists.

DELETE /api/v1/tag/<tag_id>

Delete the specified tag

Response

StatusDescription
200 SuccessThe tag has been deleted.
404 Not FoundThe specified tag couldn't be found.