This is HavenK API to make easy to manage and store you objects and clients data
All API requests are composed of light-weight JSON delivered as an HTTP POST request to the endpoint URL.
All JSON should be UTF-8 encoded.
Date and time values are of the form YYYY-MM-DD HH:MM:SS.
Booleans are either 1 (true) or 0 (false).
For requests to the RESTful JSON interface, you need to set the Authorization key using the NAS-Authorization header field. The key needs to be present for each request.
NAS-Authorization: {AuthKey}
<?php
define('API_KEY', 'API_hash');
define('BASE_URL', 'https://havenk.nasys.no/api');
function getData($method, $url, $data = array()) {
$data_string = json_encode($data);
$header = array("Content-Type: application/json",
"Content-Length: ". strlen($data_string),
"NAS-Authorization: ".API_KEY);
$ch = curl_init(BASE_URL.$url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
return curl_exec($ch);
}
$data = json_decode(getData('GET', '/account/0/100'), true);
echo '<pre>'.print_r($data,true).'</pre>';
?>
All responses are wrapped in a top-level response element. The status attribute will let you know whether the request succeeded or failed. Status can be OK or ERROR. In all cases, the API should return an HTTP Status Code that indicates the nature of the failure (below), with a response body in JSON format containing additional information.
Code | Message | Description |
---|---|---|
200 | Success |
If data was requested, it will be available
in the data field at the top level of the response body.
|
400 | Invalid request | This usually occurs because of a missing or malformed parameter. Check the documentation and the syntax of your request and try again. |
401 | No authorization | A valid API key was not provided with the request, so the API could not associate a user with the request. |
403 | Forbidden | The API key was wrong. |
500 | Server error | There was a problem on our end. |
GET | /api/account/{account_id} | get account by given account ID |
Respond{ "id": "string", "name": "string", "credit": "boolean", "active": "boolean" } | ||
GET | /api/account/{card_nr} | get account by given card number |
Respond{ "id": "string", "name": "string", "credit": "boolean", "active": "boolean" } | ||
GET | /api/account/{account_id}/card/{offset}/{limit}/{asc/desc} | get list of account cards by given account ID |
Respond{ "results": [ { "id": "string", "account_id": "number", "name": "string", "card_nr": "string" } ], "totalCount": "string" } | ||
GET | /api/account/{offset}/{limit}/{asc/desc} | get list of all accounts by given offset and limit |
Respond{ "results": [ { "id": "string", "name": "string", "credit": "boolean", "active": "boolean" } ], "totalCount": "string" } | ||
POST | /api/account | create new account |
Request{ "name": "string", "credit": "0", "active": "boolean" }Respond { "id": "string", "name": "string", "credit": "boolean", "active": "boolean" } | ||
POST | /api/account/login | Account authorization |
PS: password is in sha1 (ascii mode) and after that also converted to base64 Request{ "email": "string", "password": "string" }Respond { "id": "id", "name": "string", "email": "string", "credit": "string", "active": "string", "status": "Success" }Error Respond { "status": "Error", "text": "string" } | ||
POST | /api/account/register | Virtual Account registration |
PS: password is in sha1 (ascii mode) and after that also converted to base64 Request{ "name": "string", "email": "string", "password": "string" }Respond { "id": "id", "name": "string", "email": "string", "credit": "string", "active": "string", "card_nr": "string", "status": "Success" }Error Respond { "status": "Error", "text": "string" } | ||
PATCH | /api/account/{id} | patch card to account |
Request{ "card_nr": "string" }Respond { "status": "string", "card_nr": "string" } | ||
PUT | /api/account/{id} | update account by given ID |
Request{ "name": "string", "credit": "0", "active": "boolean" }Respond { "id": "string", "name": "string", "credit": "boolean", "active": "boolean" } | ||
DELETE | /api/account/{id} | delete account by given ID |
Respond{} |
PS: Account_id can be NULL, then this card is not connected to account.
GET | /api/card/{id} | get card by given ID |
Respond{ "id": "string", "account_id": "string", "name": "string", "card_nr": "string", "serial_nr": "string", "created": "string" } | ||
GET | /api/card/{offset}/{limit}/{asc/desc} | get list of cards by given offset and limit |
Respond{ "results": [ { "id": "string", "account_id": "string", "name": "string", "card_nr": "string", "serial_nr": "string", "created": "string" } ], "totalCount": "string" } | ||
POST | /api/card | create a new card |
Request{ "account_id": "string", "name": "string", "card_nr": "string", "serial_nr": "string" }Respond { "id": "string", "account_id": "string", "name": "string", "card_nr": "string", "serial_nr": "string", "created": "string" } | ||
PUT | /api/card/{id} | update card by given ID |
Request{ "account_id": "string", "name": "string", "card_nr": "string", "serial_nr": "string" }Respond { "id": "string", "account_id": "string", "name": "string", "card_nr": "string", "serial_nr": "string", "created": "string" } | ||
DELETE | /api/card/{id} | delete card by given ID |
Respond{} |
GET | /api/object/{id} | get object by given ID |
Respond{ "id": "id", "name": "string", "group_id": "string", "cost": "string", "time": "string", "created": "string", "status": "string" } | ||
GET | /api/object/GID/{id}/{offset}/{limit}/{asc/desc} | get list objects from group by given group_id |
Respond{ "id": "id", "name": "string", "group_id": "string", "cost": "string", "time": "string", "created": "string", "status": "string" } | ||
GET | /api/object/{offset}/{limit}/{asc/desc} | get objects by given limit and offset |
Respond{ "results": [ { "id": "id", "name": "string", "group_id": "string", "cost": "string", "time": "string", "created": "string", "status": "string" } ], "totalCount": "string" } | ||
POST | /api/object | create a new object |
Request{ "name": "string", "group_id": "string", "cost": "string", "time": "string" }Respond { "id": "id", "name": "string", "group_id": "string", "cost": "string", "time": "string", "created": "string", "status": "string" } | ||
PUT | /api/object/{id} | update object by given ID |
Request{ "name": "string", "group_id": "string", "cost": "string", "time": "string" }Respond { "id": "id", "name": "string", "group_id": "string", "cost": "string", "time": "string", "created": "string", "status": "string" } | ||
DELETE | /api/object/{id} | delete object by given ID |
Respond{} |
GET | /api/group/{id} | get group by given ID |
Respond{ "id": "string", "name": "string", "description": "string" } | ||
GET | /api/group/{offset}/{limit}/{asc/desc} | get list of groups by given offset and limit |
Respond{ "results": [ { "id": "string", "name": "string", "description": "string" } ], "totalCount": "string" } | ||
POST | /api/group | create a new group |
Request{ "name": "string", "description": "string" }Respond { "id": "string", "name": "string", "description": "string" } | ||
PUT | /api/group/{id} | update group by given ID |
Request{ "name": "string", "description": "string" }Respond { "id": "string", "name": "string", "description": "string" } | ||
DELETE | /api/group/{id} | delete group by given ID |
Respond{} |
Creating or updating status with card nr, then systems find account_id automatically
GET | /api/status/{id} | get status by given ID |
Respond{ "id": "id", "account_id": "string", "group_id": "string", "object_id": "string", "part_id": "string", "credit": "string", "start_time": "string", "end_time": "string", "created": "string", "modified": "string" } | ||
GET | /api/status/{offset}/{limit}/{asc/desc} | get list of status by given offset and limit |
Respond{ "results": [ { "id": "id", "account_id": "string", "group_id": "string", "object_id": "string", "part_id": "string", "credit": "string", "start_time": "string", "end_time": "string", "created": "string", "modified": "string" } ], "totalCount": "string" } | ||
GET | /api/status/AID/{id}/{offset}/{limit}/{asc/desc} | get list of status by given AID |
Respond{ "id": "id", "account_id": "string", "group_id": "string", "object_id": "string", "part_id": "string", "credit": "string", "start_time": "string", "end_time": "string", "created": "string", "modified": "string" } | ||
POST | /api/status/card/{card_nr} | create a new status by given card nr |
Request{ "group_id": "string", "object_id": "string", "part_id": "string", "credit": "string", "start_time": "string", "end_time": "string" }Respond { "id": "id", "account_id": "string", "group_id": "string", "object_id": "string", "part_id": "string", "credit": "string", "start_time": "string", "end_time": "string", "created": "string", "modified": "string" } | ||
POST | /api/status | create a new status |
Request{ "account_id": "string", "group_id": "string", "object_id": "string", "part_id": "string", "credit": "string", "start_time": "string", "end_time": "string" }Respond { "id": "id", "account_id": "string", "group_id": "string", "object_id": "string", "part_id": "string", "credit": "string", "start_time": "string", "end_time": "string", "created": "string", "modified": "string" } | ||
PUT | /api/status/{id}/card/{card_nr} | update status by given ID and card nr |
Request{ "group_id": "string", "object_id": "string", "part_id": "string", "credit": "string", "start_time": "string", "end_time": "string" }Respond { "id": "id", "account_id": "string", "group_id": "string", "object_id": "string", "part_id": "string", "credit": "string", "start_time": "string", "end_time": "string", "created": "string", "modified": "string" } | ||
PUT | /api/status/{id} | update status by given ID |
Request{ "account_id": "string", "group_id": "string", "object_id": "string", "part_id": "string", "credit": "string", "start_time": "string", "end_time": "string" }Respond { "id": "id", "account_id": "string", "group_id": "string", "object_id": "string", "part_id": "string", "credit": "string", "start_time": "string", "end_time": "string", "created": "string", "modified": "string" } | ||
DELETE | /api/status/{id} | delete status by given ID |
Respond{} | ||
DELETE | /api/status/AID/{id} | delete status by given AID |
Respond{} |
Outputs information about your account
GET | /api/me | get info about your account |
Respond{ "id": "id", "name": "string", "sites": [ "string" ] } |
Can validate system user
PS: password is in sha1 (ascii mode) and after that also converted to base64
POST | /api/login | System user authorization |
Request{ "email": "string", "password": "string" }Respond { "id": "id", "name": "string", "email": "string", "status": "Success" }Error Respond { "status": "Error", "text": "string" } |