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 help you to create doors to your BioStar 2 via using New local API. 

 

This article includes a ‘Create Door’ part of a sample application made for those who might need to use the BioStar 2 New Local API. It is a Visual C# console application.

 

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 

 

  1. How to Create Doors

 

Method

API

What it does

Parameters

POST

 

/api/doors

Creates doors in BioStar 2

*Check below

 

 

[POST]: /api/doors

[Parameters] 

Name

Type

*M/O

Explanation

Value

Exit_button_input_id.device_id.id

Int

O

Exit device ID

 

Exit_button_input_id.device_id.name

String

O

Exit device name

Base64

Exit_button_input_id.input_index

Int

O

Exit input index

 

Exit_button_input_id.type

String

O

Exit input type

 

Exit_button_input_id.supervised

String

O

Exit Supervised

 

Sensor_input_id.device_id.id

Int

O

Sensor device ID

 

Sensor_input_id.device_id.name

String

O

Sensor device name

Base64

Sensor_input_id..input_index

Int

O

Sensor input index

 

Sensor_input_id.type

String

O

Sensor input type

 

Sensor_input_id.supervised

String

O

Sensor supervised

 

Antitailsensor_input_id.device_id

array

O

Antitail sensor input device ID

 

Antitailsensor_input_id.type

String

O

Antitailsensor input type

 

Open_duration

Int

O

Open duration

 

Dual_authentication.device

String

O

Device Type

1- Entry Device
 2- Exit Device

Dual_authentication.approval_type

String

O

Approval Order

1- Last

Dual_authentication.timeout

Int

O

Timeout Time

Example: 15

Dual_authentication.schedule_id.id

String

O

Schedule ID

Example: 1

Dual_authentication.approval_groups

String

O

Approval groups

 

Open_once

Boolean

O

Look when door is closed

Example: false

Unconditional_lock

Boolean

O

Use Automatic Door

Default: false

Door_group_id.id

Int

O

Door Group ID

Default: 0

Door_group_id.name

String

O

Door Group Name

Example: All Doors

Entry_device_id.id

Int

M

Entry Device ID

 

Entry_device_id.name

String

M

Entry Device Name

Base64

Entry_device_id.device_type_id

Int

M

Device Type ID

BIOENTRY_PLUS : 1,

BIOENTRY_W : 2,

BIOLITE_NET : 3,

XPASS : 4,

XPASS_S2 : 5,

ENTRY_MAX : 5,

SECURE_IO_2 : 6,

DOOR_MODULE_20 : 7,

BIOSTATION_2 : 8,

BIOSTATION_A2 : 9,

FACESTATION_2 : 10,

IO_DEVICE : 11,

BIOSTATION_L2 : 12,

BIOENTRY_W2 : 13,

CORESTATION_40 : 14,

OUTPUT_MODULE : 15,

INPUT_MODULE : 16,

BIOENTRY_P2 : 17,

BIOLITE_N2 : 18,

XPASS2 : 19,

XPASS_S3 : 20,

BIOENTRY_R2 : 21,

XPASS_D2 : 22,

DOOR_MODULE_21 : 23,

XPASS_D2_KEYPAD : 24,

FACELITE : 25,

XPASS2_KEYPAD : 26,

MAX = BS2_DEVICE_TYPE_XPASS2_KEYPAD, : 26,

UNKNOWN : 255,

Trigger_actions.input_event_id

String

O

Code

Example: 22528

Trigger_actions.output_device_id.id

Int

O

Device ID

 

Trigger_actions.output_device_id.name

String

O

Device Name

Base64

Trigger_actions.output_device_id.device_type_id.id

Int

O

Device Type ID

BIOENTRY_PLUS : 1,

BIOENTRY_W : 2,

BIOLITE_NET : 3,

XPASS : 4,

XPASS_S2 : 5,

ENTRY_MAX : 5,

SECURE_IO_2 : 6,

DOOR_MODULE_20 : 7,

BIOSTATION_2 : 8,

BIOSTATION_A2 : 9,

FACESTATION_2 : 10,

IO_DEVICE : 11,

BIOSTATION_L2 : 12,

BIOENTRY_W2 : 13,

CORESTATION_40 : 14,

OUTPUT_MODULE : 15,

INPUT_MODULE : 16,

BIOENTRY_P2 : 17,

BIOLITE_N2 : 18,

XPASS2 : 19,

XPASS_S3 : 20,

BIOENTRY_R2 : 21,

XPASS_D2 : 22,

DOOR_MODULE_21 : 23,

XPASS_D2_KEYPAD : 24,

FACELITE : 25,

XPASS2_KEYPAD : 26,

MAX = BS2_DEVICE_TYPE_XPASS2_KEYPAD, : 26,

UNKNOWN : 255,

Trigger_actions.output_device_id.status

String

O

Status

Example: 2

Trigger_actions.output_device_id.rs485.mode

String

O

RS485 mode

Example: 1

Trigger_actions.output_device_id.rs485.channels

array

O

Channels

 

Trigger_actions.output_device_id.rs485.parent_rs485.info

String

O

Parent RS485 information

 

Trigger_actions.output_device_id.device_group_id.id

Int

O

Device Group ID

 

Trigger_actions.output_device_id.device_group_id.name

String

O

Device Group Name

 

Trigger_actions.output_device_id.version.firmware

String

O

Firmware version

Example: 1.1.0

Trigger_actions.output_device_id.version.product_name

String

O

Product name

Example: BLN2-OAB

Trigger_actions.output_device_id.lan.ip

String

O

IP

Example: 192.168.12.168

Trigger_actions.output_device_id.lan.connection_mode

String

O

Connection Mode

Example: 0

Trigger_actions.output_device_id.tna..mode

String

O

TnA Mode

Example: 3

Trigger_actions.output_device_id.tna..required

Boolean

O

TnA Required

Example: false

Trigger_actions.output_device_id.tna..fixed_code

String

O

TnA Fixed Code

 

Trigger_actions.output_device_id.tna..tna_keys.enabled

Boolean

O

Use TnA Keys

 

Trigger_actions.output_device_id.tna..tna_keys.label

String

O

TnA Keys Label

 

Trigger_actions.output_device_id.tna..tna_keys.icon

String

O

TnA Keys Icon

 

Trigger_actions.output_device_id.slave_devices

Array

O

Slave Devices

 

Trigger_actions.output_device_id.packet_version

Int

O

Packet Version

 

Trigger_actions.output_device_id.iconCls

String

O

Icon Class

Example: dvBioLiteN2 sync_error

Trigger_actions.output_device_id.deviceData.id

Int

O

Device ID

Example: 635

Trigger_actions.output_device_id.deviceData.name

String

O

Device Name

Base64

Trigger_actions.output_device_id.deviceData.device_type_id.id

Int

O

Device type ID

BIOENTRY_PLUS : 1,

BIOENTRY_W : 2,

BIOLITE_NET : 3,

XPASS : 4,

XPASS_S2 : 5,

ENTRY_MAX : 5,

SECURE_IO_2 : 6,

DOOR_MODULE_20 : 7,

BIOSTATION_2 : 8,

BIOSTATION_A2 : 9,

FACESTATION_2 : 10,

IO_DEVICE : 11,

BIOSTATION_L2 : 12,

BIOENTRY_W2 : 13,

CORESTATION_40 : 14,

OUTPUT_MODULE : 15,

INPUT_MODULE : 16,

BIOENTRY_P2 : 17,

BIOLITE_N2 : 18,

XPASS2 : 19,

XPASS_S3 : 20,

BIOENTRY_R2 : 21,

XPASS_D2 : 22,

DOOR_MODULE_21 : 23,

XPASS_D2_KEYPAD : 24,

FACELITE : 25,

XPASS2_KEYPAD : 26,

MAX = BS2_DEVICE_TYPE_XPASS2_KEYPAD, : 26,

UNKNOWN : 255,

Trigger_actions.output_device_id.deviceData.device_type_id.status

Int

O

Status

 

Trigger_actions.output_device_id.deviceData.device_type_id.rs485.mode

String

O

RS485 mode

 

Trigger_actions.output_device_id.deviceData.device_type_id.rs485.channels

Array

O

Channels

 

Trigger_actions.output_device_id.deviceData.device_type_id.rs485.parent_rs485_info

String

O

Parent Rs485 Information

 

Trigger_actions.output_device_id.deviceData.device_type_id.device_group_id.id

Int

O

Device Group ID

 

Trigger_actions.output_device_id.deviceData.device_type_iddevie_group_id.name

String

O

Device Group Name

 

Trigger_actions.output_device_id.deviceData.device_type_id.version.firmware

String

O

Firmware Version

Example: 1.1.0

Trigger_actions.output_device_id.deviceData.device_type_id.version.product_name

String

O

Product Name

Example: BLN2-OAB

Trigger_actions.output_device_id.deviceData.device_type_id.lan.ip

String

O

IP

 

Trigger_actions.output_device_id.deviceData.device_type_idlan.connection_mode

String

O

Connection Mode

 

Trigger_actions.output_device_id.deviceData.device_type_id.tna.mode

String

O

TnA Mode

 

Trigger_actions.output_device_id.deviceData.device_type_id.tna.required

String

O

TnA required

 

Trigger_actions.output_device_id.deviceData.device_type_id.tna.fixed_code

String

O

TnA Fixed Code

 

Trigger_actions.output_device_id.deviceData.device_type_id.tna.tna_keys.enabled

Boolean

O

Use TnA Keys

 

Trigger_actions.output_device_id.deviceData.device_type_id.tna.tna_keys.label

String

O

TnA Label

 

Trigger_actions.output_device_id.deviceData.device_type_id.tna.tna_keys.icon

String

O

TnA Icon

 

Trigger_actions.output_device_id.deviceData.device_type_id.slave_devices

Array

O

Slave Devices

 

Trigger_actions.output_device_id.deviceData.device_type_id.packet_version

Int

O

Packet Version

 

Trigger_actions.output_device_id.deviceData.device_type_id.iconCls

String

O

Icon Class

 

Trigger_actions.output_device_id.sound

Boolean

O

Sound

 

Trigger_actions.output_type

Int

O

Output Type

 

Trigger_actions.sound_index

Int

O

Sound Index

 

Trigger_actions.stop_flag

Int

O

Stop Flag

 

Trigger_actions.$$hashKey

String

O

No Required

Example: object:3207

Relay_output_id.device_id

Int

M

Device ID

 

Relay_output_id.relay_index

Int

M

Relay index

 

Open_timeout

Int

 

Open Timeout

 

Name

String

M

Name

 

Door_anti_passback

Array

O

Door Anti Passback

 

   * M – Mandatory, O – Optional

 

Part 2. Request Body & Response Model


[Example Value/Parameters Model]

{

  "Door": {

    "exit_button_input_id": {

      "device_id": {

        "id": 635,

        "name": "Base64: RDQQFJYAVUYvFXsEIzIQC1QYbodkHe..."

      },

      "input_index": 0,

      "type": "0",

      "supervised": ""

    },

    "sensor_input_id": {

      "device_id": {

        "id": 635,

        "name": "Base64: RDQQFJYAVUYvFXsEIzIQC1QYbodkHe..."

      },

      "input_index": 0,

      "type": "0",

      "supervised": ""

    },

    "antitailsensor_input_id": {

      "device_id": {},

      "type": "0"

    },

    "open_duration": 3,

    "dual_authentication": {

      "device": "1",

      "approval_type": "1",

      "timeout": 15,

      "schedule_id": {

        "id": "1"

      },

      "approval_groups": [

        null

      ]

    },

    "open_once": "false",

    "unconditional_lock": "true",

    "door_group_id": {

      "id": 1,

      "name": "All Doors"

    },

    "entry_device_id": {

      "id": 635,

      "name": "Base64: RDQQFJYAVUYvFXsEIzIQC1QYbodkHe...",

      "device_type_id": {

        "id": 18

      }

    },

    "trigger_actions": [

      {

        "input_event_id": {

          "code": "22528"

        },

        "output_device_id": {

          "id": 635,

          "name": "Base64: RDQQFJYAVUYvFXsEIzIQC1QYbodkHe...",

          "device_type_id": {

            "id": 18

          },

          "status": "2",

          "rs485": {

            "mode": "1",

            "channels": [

              null

            ],

            "parent_rs485_info": ""

          },

          "device_group_id": {

            "id": 1,

            "name": "All Devices"

          },

          "version": {

            "firmware": "1.1.0",

            "product_name": "BLN2-OAB"

          },

          "lan": {

            "ip": "192.168.12.165",

            "connection_mode": "0"

          },

          "tna": {

            "mode": "3",

            "required": "false",

            "fixed_code": "1",

            "tna_keys": [

              {

                "enabled": "false",

                "label": "",

                "icon": "0"

              }

            ]

          },

          "slave_devices": [

            null

          ],

          "packet_version": 2,

          "iconCls": "dvBioLiteN2 sync_error",

          "deviceData": {

            "id": 635,

            "name": "Base64: RDQQFJYAVUYvFXsEIzIQC1QYbodkHe...",

            "device_type_id": {

              "id": 18

            },

            "status": 2,

            "rs485": {

              "mode": "1",

              "channels": [

                null

              ],

              "parent_rs485_info": ""

            },

            "device_group_id": {

              "id": 1,

              "name": "All Devices"

            },

            "version": {

              "firmware": "1.1.0",

              "product_name": "BLN2-OAB"

            },

            "lan": {

              "ip": "192.168.12.165",

              "connection_mode": "0"

            },

            "tna": {

              "mode": "3",

              "required": "false",

              "fixed_code": "1",

              "tna_keys": [

                {

                  "enabled": "false",

                  "label": "",

                  "icon": "0"

                }

              ]

            },

            "slave_devices": [

              null

            ],

            "packet_version": 2,

            "iconCls": "dvBioLiteN2 sync_error"

          },

          "sound": true

        },

        "output_type": 2,

        "sound_index": 4,

        "stop_flag": 1,

        "$$hashKey": "object:3207"

      }

    ],

    "relay_output_id": {

      "device_id": {

        "id": 635

      },

      "relay_index": 0

    },

    "open_timeout": 3,

    "name": "d22",

    "door_anti_passback": {}

  }

}

 

[Response Model]

{

     "DoorCollection": {

       "total": "1",

       "rows": [

         {

           "id": "3",

           "name": "d22"

         }

       ]

     },

     "DeviceResponse": {

       "rows": [

         {

           "id": "541530960",

           "seq": "37",

           "command": "0x500(BS2_CMD_SET_DOOR)",

           "code": "64230"

         }

       ],

       "result": "false"

     },

     "Response": {

       "code": "0",

       "link": "https://support.supremainc.com/en/support/home",

       "message": "Success"

     },

     "httpResponseStatus": 200

}

 

[Response: Fail]

{

       "Response": {

           "code": "10",

           "link": "https://support.supremainc.com/en/support/home",

           "message": "Login required."

       }

}

 

[Response: Successful]

{

     "DoorCollection": {

       "total": "1",

       "rows": [

         {

           "id": "34",

           "name": "Door3223"

         }

       ]

     },

     "Response": {

       "code": "0",

       "link": "https://support.supremainc.com/en/support/home",

    "message": "Success"

     }

}

 

Part 3. Console Create Door Example

 

[Create Door Method Source Code] 

static async void CreateDoor()

        {

            Console.WriteLine("*****CreateDoor Task Started******");

            if (sessionID == null)

            {

                Console.WriteLine("You must log in first!");

                return;

            }

            CookieContainer cookieContainer = new CookieContainer();

 

            HttpClientHandler handler = new HttpClientHandler();

            handler.CookieContainer = cookieContainer;

 

            HttpClient httpClient = new HttpClient(handler);

 

            HttpClient client = new HttpClient(handler);

               httpClient.DefaultRequestHeaders.Add("bs-session-id", sessionID);

            cookieContainer.Add(new Uri(BioStarIP), new Cookie("bs-session-id", sessionID));

            string resourceAddress = BioStarIP + "/api/doors";

 

            JavaScriptSerializer serializer = new JavaScriptSerializer();

            Console.WriteLine("Enter Door Name: ");

            string name = Console.ReadLine();

            ListDevices();

            Console.WriteLine("Enter Relay Device ID: ");

            string RelayDeviceID = Console.ReadLine();

            string payload = "{{\"Door\":{\"door_group_id\":{\"id\":1,\"name\":\"AllDoors\"},\"entry_device_id\":{},\"relay_output_id\":{\"device_id\":{\"id\":" + RelayDeviceID + "},\"relay_index\":1},\"open_timeout\":3,\"name\":\"" + name + "\",\"door_anti_passback\":{}}}}";

            Console.WriteLine(payload);

            StringContent sc = new StringContent(payload, Encoding.UTF8, "application/json");

            HttpResponseMessage httpResponse = httpClient.PostAsync(resourceAddress, sc).Result;

 

            if (httpResponse.IsSuccessStatusCode == true)

            {

                Console.WriteLine("Create Door Successful.");

                string httpResponseBody = await httpResponse.Content.ReadAsStringAsync();

                   Console.WriteLine(httpResponseBody);

            }

            else

            {

                Console.WriteLine("Create Door Failed.");

                   Console.WriteLine(httpResponse.ToString());

            }

        }

 

[After Create Door Successfully] 

 텍스트이(가) 표시된 사진

자동 생성된 설명

 

*Input Door Name

*Show Device List

*Select device by device_id to add to the door as its Relay Device

 

Part 4. Create Door 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] 

텍스트, 스크린샷, 모니터, 화면이(가) 표시된 사진

자동 생성된 설명

*Only necessary parameters are written in the Request Body

 

[Response Example: body] 

텍스트이(가) 표시된 사진

자동 생성된 설명