# 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' "
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.honey.co.th/honey-modbus-io/restapi-for-modbus-io.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
