Skip to main content

API Reference Manual

Content

Authentication:

Collections behaviour:

Errors:

Authentication

Users authentication

API supports Bearer Authentication (token authentication) with JSON Web Token (JWT). JWT is issued by the server in response to a sign-in request (session create). The client must send this token in the Authorization header in order to authenticate himself:

Authorization: Bearer <token>

Token is exposed to the client only once after fresh session is created and should be securely stored in user's client application.

General endpoint behaviour

Embedding

Some resources also support embedding of some relationships or additional properties. To embed something, use embed argument in url query with value consisting of embeded fields separated by comma. For example, to embed relationship role_ids and roles_count, use ?embed=role_ids,roles_count in URL query of your request. Embedding is possible either for requests on collections and single model (for all methods available).

Embedded fields are returned within object of a model as a dictionary in property _embedded.

{
"id": 1,
"_embedded": {
"role_ids": [1,4],
"roles_count": 2
}
}

Collections behaviour

Filtering

Filters can be used on most resources returning collection of some data. There is a lot of variations how to filter data, so filters must be encoded in base64.

There are defined basic operations to compare values while filtering:

OperatorDescriptionLimitations
eqequals (==)Can be used with every type.
neqnot equals (!=)Can be used with every type.
inone of the values must equalCan only be used with array. Does not make sense for bool[].
gtgreater than (>)Can be used only with int, decimal, date.
gtegreater than or equal to (>=)Can be used only with int, decimal, date.
ltless than (<)Can be used only with int, decimal, date.
lteless than or equal to (<=)Can be used only with int, decimal, date.
containschecks string contains substringCan be used only with string.
starts_withchecks string starts with substringCan be used only with string.
ends_withchecks string ends with substringCan be used only with string.

And these basic types:

TypeDescriptionOperators supported
stringsequence of characterseq, neq, in, starts_with, ends_with, contains
int64 bit integereq, neq, in, gt, gte, lt, lte
enumenumerator or model identifier, int or stringeq, neq, in
boolboolean, true or falseeq, neq
decimalnumber with fixed decimal pointeq, neq, in, gt, gte, lt, lte
dateDate or DateTimeeq, neq, in, gt, gte, lt, lte

Filter object has following structure:

ParamTypeDescription
fstring[]For each specified field filter will be applied with operator o and value v.
ostringOperator that should apply.
vanyValue of filter. For operator in can be array, for other operators must be scalar value.

One or more filter object have to be put into single array and encoded to base64 before sending as a value of filters URL parameter.

Example:

We want to get only records with identifiers 1, 5 and 24:

First, filters collection has to be created:

[
{
"f": ["id"],
"o": "in",
"v": [1, 5, 24]
}
]

Than, this collection has to be JSON encoded and than encoded to base64 like this (equal signs can be omitted):

W3siZiI6WyJpZCJdLCJvIjoiaW4iLCJ2IjpbMSw1LDI0XX1d

and send it as fitlers URL parameter:

GET /api/resource?filters=W3siZiI6WyJpZCJdLCJvIjoiaW4iLCJ2IjpbMSw1LDI0XX1d HTTP/1.1

Sorting

For sorting, send URL parameter sort with name of columns you want to sort. For ascending sorting use ?sort=column_name, for descending sorting use minus sign before column name, like ?sort=-column_name.

Sorting is supported for multiple columns at once - columns must be separated by comma sign, like ?sort=-column_a,column_b.

Pagination

Some resources might be paginated by default. For turning pagination on or off just use URL parameter paginated - value 1 turns pagionation on, value 0 turns pagination off.

By default, there are 20 items per one page. This can be changed by specifying number of items per page with URL parameter per_page.

To change the page send URL parameter page with required page number.

Errors

General description

All errors will have same structure:

ParamTypeDescription
idstringA unique identifier for this particular occurrence of the problem.
typestringAn application-specific error code, expressed as a string value.
messagestringHuman-readable summary of the problem. Can be localized.
errorsFieldError[]An array of errors related to particular fields in request. This field is present when 422 error is returned.

Example #1:

{
"type": "NotFound",
"message": "Required model was not found.",
"id": "0cd85449-05fe-4866-9802-8192e6785fc7"
}

Example #2:

{
"type": "ValidationError",
"message": "The given data was invalid.",
"id": "5c99f70a-e400-44bb-9cd4-592b0a30e145",
"errors": [
{
"field": "email",
"message": "The email field is required."
}
]
}