Page tree
Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 20 Next »

 

Overview

Basics

The Unimus API is a JSON based RESTfull API. It utilizes common HTTP methods such as GET, POST, PATCH and DELETE in order to identify action you want to perform.

When submitting a request that contains a body you must include a header for Content-type that specifies application/json.

Security

Every request has to include Authorization header following Bearer scheme as shown below.

Authorization: Bearer <token>

Log into your local Unimus instance and navigate to User management > API tokens section to create new token.

Returned data format

All responses are returned as JSON. If a response can ever contain a single item it will be formatted as follow:

{

"data": {
"some key": "some value",
"another key": "another value"
}

}

Multi-item responses are paginated automatically. The maximum amount of items that can be returned in a single query is 50, default is 20. You may specify the number of items to be returned in response by appending a query parameter size.

You may specify the page you wish to view by appending a parameter page, default is 0. Multi-item responses are formatted as follow:

{

"data":  [
  {
"some key": "some value",
"another key": "another value"
},
{
"some key": "some value",
"another key": "another value"
}
 ],
"paginator": {
"totalCount": 12,
"totalPages": 6,
"page": 0,
"size": 2
}

}

All successful response are sent with an HTTP response code 2xx.

Failure response format

If an API response fails, it will be sent with a non-2xx response code and JSON in the following format:

{

"timestamp": 1511904038642
"code": 400
"error": "Bad Request"
"message": "This is why it fails"

}

The HTTP status codes currently returned by the API are 400 if request syntax is wrong, 401 if request is unauthorized, 404 if requesting with item ID and item is not found or request path is not supported by the API, 405 if the method is not supported, 415 if media type is not supported, 503 if request can not be served. Any internal application errors will respond with a 500 code and we will be grateful if u report them to us. 

API documentation

General

Health check

Get Unimus health status.

Method: GET

CURL

curl -H "Accept: application/json" -H "Authorization: Bearer <token>" "http://<example.unimus>/api/v1/health"

Success 200

FieldTypeDescription
statusString

OK - Unimus is ready to handle all requests.

LICENSING_UNREACHABLE - License server is unreachable. All request will proceed except add, remove and update device.

ERROR - Unimus require user interaction to solve the problem. All requests will be refused.

Success response

 HTTP/1.1 200 OK

{

"data": {
"status": "OK"
}

}

 

 


 

Schedules

Schedules - get schedule

Get an individual schedule.

Method: GET

CURL

curl -H "Accept: application/json" -H "Authorization: Bearer <token>" "http://<example.unimus>/api/v1/schedules/<scheduleId>"

Parameter

FieldTypeDescription
scheduleIdNumberThe ID of the schedule

Success 200

FieldTypeDescription
 idNumber  The ID of the schedule
createTimeNumberSchedule creation time in seconds
periodicityStringSchedule periodicity. Possible values: MONTHLY, WEEKLY, DAILY, HOURLY
domNumberDay of month
dowNumberDay of week
hourNumberHour of day
minNumberMinute of hour
nameStringSchedule pretty name
Success response

HTTP/1.1 200 OK

{

"data": {
"id": 7,
"createTime": 1511863250,
"periodicity": "MONTHLY",
"dom": 1,
"dow": 1,
"hour": 0,
"min": 6,
"name": "Every month, on day 1, at 00:06."
}

}

Error 4xx

NameTypeDescription
timestamp Number Current timestamp
 code Number404
 error String HTTP code message
 messageString  Error message
Error response

HTTP/1.1 404 NOT FOUND

{

"timestamp": 1511862182524,
"code": 404,
"error": "Not Found",
"message": "Schedule with id 11 not found"

}


  • No labels