> For the complete documentation index, see [llms.txt](https://docs.honey.co.th/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.honey.co.th/honey-modbus-io/restapi-for-modbus-io.md).

# RESTApi for Modbus IO

## RESTApi for Modbus IO

#### **การใช้งาน RESTApi สำหรับอุปกรณ์ Modbus IO**

* [**การอ่านสถานะต่างๆ ของบอร์ด Modbus IO**](#modbus-io)
* [**การสั่งงานสถานะต่างๆ ของบอร์ด Modbus IO**](#modbus-io-1)

## **การอ่านสถานะต่างๆ ของบอร์ด Modbus IO**

🔗 \[GET] <https://api.honey.co.th/devices/><mark style="color:red;">**:serial\_number**</mark>

#### Path Parameters

| Name               | Type   | Description          |
| ------------------ | ------ | -------------------- |
| :serial\_number \* | string | Device Serial Number |

#### **Query Parameters ( option )**

| Name   | Type   | Description                               |
| ------ | ------ | ----------------------------------------- |
| apikey | string | API Key (สามารถดูได้จากหน้า HONEYConsole) |

#### **Headers Parameters ( option )**

| Name   | Type   | Description                               |
| ------ | ------ | ----------------------------------------- |
| apikey | string | API Key (สามารถดูได้จากหน้า HONEYConsole) |

#### Example Request

\#️⃣ curl '<https://api.honey.co.th/devices/><mark style="color:red;">**:serial\_number**</mark>?apikey=<mark style="color:red;">**:apikey**</mark>'

#### Response Success ( 200 : OK )

```json
{
  "success": true,
  "data": {
	  // response data
  }
}
```

#### Response Unauthorized ( 401 : Unauthorized )

```json
{
  "success": false,
  "data": {},
  "msg": "require query params! -> 'apikey' "
}
```

***

## **การสั่งงานสถานะต่างๆ ของบอร์ด Modbus IO**

🔗 \[POST] <https://api.honey.co.th/devices/><mark style="color:red;">**:serial\_number**</mark>

#### Path Parameters

| Name               | Type   | Description          |
| ------------------ | ------ | -------------------- |
| :serial\_number \* | string | Device Serial Number |

#### **Query Parameters ( option )**

| Name   | Type   | Description                               |
| ------ | ------ | ----------------------------------------- |
| apikey | string | API Key (สามารถดูได้จากหน้า HONEYConsole) |

#### **Headers Parameters ( option )**

| Name   | Type   | Description                               |
| ------ | ------ | ----------------------------------------- |
| apikey | string | API Key (สามารถดูได้จากหน้า HONEYConsole) |

#### **Request Body**

| Name      | Type | Description                                                                        |
| --------- | ---- | ---------------------------------------------------------------------------------- |
| VAR\_Y0   | bool | ควบคุม Y0 ให้เปิด / ปิด                                                            |
| VAR\_Y(n) | bool | ควบคุม Y ที่ n ให้เปิด / ปิด เช่น ต้องการควบคุม Y7 จะต้อง key เป็น VAR\_Y7 เป็นต้น |

#### Example Request

\#️⃣ curl '<https://api.honey.co.th/devices/><mark style="color:red;">**:serial\_number**</mark>?apikey=<mark style="color:red;">**:apikey**</mark>' \ --header 'Content-Type: application/json' \ --data '{ "VAR\_Y0":1 }'

#### Response Success ( 201 : Created )

```json
{
  "success": true,
  "msg": "send command to device"
}
```

#### Response Unauthorized ( 401 : Unauthorized )

```json
{
  "success": false,
  "data": {},
  "msg": "require query params! -> 'apikey' "
}
```
