Introduction
If you’d like to use BioStar 2 New Local API as a RESTful API for your own customization or other purposes, you can simply reference this article. This article will cover the most basic usage of the BioStar 2 New Local API by C# console application.
This is just a sample application made for those who might need to use the BioStar 2 New Local API. It is a Visual C# console application.
Features
This article will cover the functions below:
- Login
- Search Users
- Create Users
- Create Users with Access Group
- Retrieve Log Data
- Retrieve Log Data with order by
Through this article, you can not only learn how to call an API function to retrieve the log data within the period of time from and to the time of your choice but also sort them by the way you want. For instance, you can sort the resulting log data in the order of time, log_id, and more. You can also adjust the [conditions] part of your request body to adjust the time period of your search of the range of ID's of your search.
Make sure you take a good look at the example code of the C# program built for API calls. You can simply copy & paste the source code to use the same function in your own integration.
You can also see how to call the API functions via Postman, which is a program used for RESTful API calls.
Part 1. API Call & Parameters
[POST]: /events/search
[Parameters]
Name | Type | *M/O | Explanation |
… |
|
|
|
limit | integer | O | # of results you want to search |
Conditions-values | String Array | O | Two datetime array for event period, the end time must be greater than the start time. *Datetime in UTC in ISO-8601 format (e.g. 2015-06-10T02:14:05.268Z ) |
Conditions-operator | integer | O | desc: Condition Operator[ EQUAL : 0, NOT_EQUAL : 1, CONTAINS : 2, BETWEEN : 3, LIKE : 4, GREATER : 5, LESS : 6] |
|
|
| You can retrieve the logs within certain period of time, id…etc. of your choice. |
orders | String Array | O | You can sort the log retrieval results by the column of your choice(i.e. id, datetime…etc.) |
* M – Mandatory, O – Optional
Part 2. Request Body & Reponse Model
[Example Value/Parameters Model]
1. Retrieve the logs within the chosen period of time & sort it by id |
{ "Query": { "limit": 500, "conditions": [ { "column": "datetime", "operator": 3, "values": [ "2021-07-01T15:00:00.000Z", "2021-08-10T14:59:59.000Z" ] } ], "orders": [ { "column": "id", "descending": false } ] } } |
*Conditions: "column" : "datetime" indicates that you’d only see the logs from the period of time between first value(time) and the second value(time).
*orders: "column" : "id" indicates you want to sort the resulting logs to be in the order of each log’s id value.
*If you change it to "orders" : " id" or other values, you can sort the logs by other values accordingly.
[Example Value/Parameters Model]
2. Retrieve the logs within the 2 chosen id values & sort it by id |
{ "Query": { "limit": 500, "conditions": [ { "column": "id", "operator": 3, "values": [ "100", "100" ] } ], "orders": [ { "column": "id", "descending": false } ] } } |
*Conditions: "column" : "id" indicates that you’d only see the logs that are between the 2 id values.
[Response: Successful]
1. Result : Retrieve the logs within the chosen period of time & sort it by id |
{ "EventCollection": { "rows": [ { "id": "1", "server_datetime": "2021-08-02T07:34:27.00Z", "datetime": "2021-08-01T22:34:26.00Z", "index": "2", "user_group_id": { "id": "0", "name": "" }, "device_id": { "id": "939271697", "name": "BioStation A2 939271697 (192.168.13.132)" }, "event_type_id": { "code": "4095" }, "is_dst": "0", "timezone": { "half": "0", "hour": "9", ... |
2. Retrieve the logs within the 2 chosen id values & sort it by id |
"EventCollection": { "rows": [ { "id": "100", "server_datetime": "2021-09-14T08:13:24.00Z", "datetime": "2021-09-13T23:13:23.00Z", "index": "451", "user_id_name": "1(Administrator)", "user_id": { "user_id": "1", "name": "Administrator", "photo_exists": "false" }, "user_group_id": { "id": "1", "name": "All Users" }, "device_id": { "id": "538747164", "name": "BioLite N2 538747164 (192.168.13.141)" }, "event_type_id": { "code": "8704" }, "is_dst": "0", "timezone": { "half": "0", "hour": "9",... |
*You must be aware that the logs can have the same id value. It is because the log data are stored in different data tables that are for each month of each year. For instance, there can be 2 logs with the same id value but from the different tables for August & September of 2021.
Part 4. Retrieve Logs via Postman
[Request Example: Headers]
*You must use the ‘be-session-id’ value from the response header of the Login API call to authenticate API use for other API calls.
[Request Example]
[Response Example: body]