tuya Device Control Cloud Services API Reference User Guide

August 9, 2024
Tuya

tuya Device Control Cloud Services API Reference

tuya-Device-Control-Cloud-Services-API-Reference-
product

Product Information

The Device Control product provides a set of APIs and instructions for controlling devices remotely. Users can send instructions to the device using the provided API endpoints.

Specifications:

  • Device Control
  • Version: 20240124
  • Online Version

Product Usage Instructions

  1. Get the Instruction Set by Category:
    Users can retrieve the instruction set by category using the following API endpoints:

    • API Description
    • API Address
    • Request Parameter
    • Return Parameter
    • Request Example
    • SDK Example
    • Response Example
    • Error Code
  2. Get the Instruction Set by Device:
    To obtain the instruction set by the device, users can utilize the provided API endpoints for specific devices. This includes details such as API address, request parameters, return parameters, and examples.

  3. Get the Instruction Set by Devices:
    This feature allows users to access the instruction set for multiple devices. Users can make requests using the API address and parameters provided.

  4. Get the Specifications and Properties of the Device:
    This API endpoint provides detailed specifications and properties of the device, including the instruction set and status set. Users can request this information along with examples of how to use the SDK.

  5. Send Instructions to the Device:
    Users can send specific instructions to the device using the provided API. This includes details such as request parameters, return parameters, and examples of how to send instructions effectively.

FAQ:

  • Q: How can I troubleshoot if I encounter errors when sending instructions?
    A: If you encounter errors when sending instructions, refer to the error code section in the API documentation to identify and troubleshoot the issue.

  • Q: Can I control multiple devices simultaneously?
    A: Yes, you can control multiple devices simultaneously by utilizing the instructions set by the device feature and making requests for each device accordingly.

This topic describes the APIs related to device control, including getting instruction sets, specifications, properties, the latest statuses, and sending instructions.

tuya-Device-Control-Cloud-Services-API-Reference-Fig-
\(1\)

Get the instruction set by category

API description
Query the instruction set by category. This instruction set has the biggest amount of instructions in the category of all-in-one apps, which can be used and referred to by developers. If you are a platform developer, you can develop applications according to this instruction set.

API address

  1. GET /v1.0/ functions /{ category}

Request parameter

tuya-Device-Control-Cloud-Services-API-Reference-Fig-
\(2\)

Return parameter

tuya-Device-Control-Cloud-Services-API-Reference-Fig-
\(3\)tuya-Device-Control-Cloud-Services-
API-Reference-Fig- \(5\)

  • Description of result
    • | Parameter name | Category | Description |
    • | :—| :—| :—|
    • | category| String | Product category |
    • | functions| List | Instruction set |
  • Description of functions
    • | Parameter name | Category | Description |
    • | :—| :—| :—|
    • | code | String | Instruction | | type | String | Instruction type |
    • | values | String | The range of input parameter values |
    • | name | String | Instruction name |
    • | desc | String | Description |

Request example

  1. GET /v1.0/ functions/kg

SDK example

tuya-Device-Control-Cloud-Services-API-Reference-Fig-
\(6\)

Response example

tuya-Device-Control-Cloud-Services-API-Reference-Fig-
\(7\) tuya-Device-Control-Cloud-Services-
API-Reference-Fig- \(8\) tuya-Device-
Control-Cloud-Services-API-Reference-Fig- \(9\)

Error code
The following are common service exceptions for this interface. For more exception errors, see Error Code.

tuya-Device-Control-Cloud-Services-API-Reference-Fig-
\(10\)

Get the instruction set by device

API description
Query the functions supported by the device. You can send control by the obtained instructions.

API address

  1. GET /v1.0/ devices /{ device_id }/ functions

Request parameter

tuya-Device-Control-Cloud-Services-API-Reference-Fig-
\(11\)

Return parameter

tuya-Device-Control-Cloud-Services-API-Reference-Fig-
\(12\)tuya-Device-Control-Cloud-Services-
API-Reference-Fig- \(13\)

  • Description of result
    • | Parameter name | Category | Description |
    • | :—| :—| :—|
    • | category| String | Product category |
    • | functions| List | Instruction set |
  • Description of functions
    • | Parameter name | Category | Description |
    • | :—| :—| :—|
    • | code | String | Instruction |
    • | type | String | Instruction type |
    • | values | String | The range of input parameter values |
    • | name | String | Instruction name |
    • | desc | String | Description |

Request example

  1. GET /v1.0/ devices/vdevo155XXXX83954683/functions

SDK example

  1. TuyaClient client = new TuyaClient(clientId , secret , RegionEnum.CN);
  2. categoryFunctions = client.getFunctionsByDevId(DEV_ID);
  3. System.out.println(“Get the function list by device ID: “);
  4. System.out.println(JSONObject.toJSONString(category Functions));

Response example

tuya-Device-Control-Cloud-Services-API-Reference-Fig-
\(14\)

Error code
The following are common service exceptions for this interface. For more exception errors, see Error Code.

tuya-Device-Control-Cloud-Services-API-Reference-Fig-
\(15\)

Get the instruction set by devices

API description
Query the functions supported by the devices List. You can send control by the obtained instructions. support up to 20 devices

API address

  1. GET /v1.0/ devices/functions

Request parameter

tuya-Device-Control-Cloud-Services-API-Reference-Fig-
\(16\)

Return parameter

tuya-Device-Control-Cloud-Services-API-Reference-Fig-
\(17\)tuya-Device-Control-Cloud-Services-
API-Reference-Fig- \(18\)

  • Description of result
    • | Parameter name | Category | Description |
    • | :—| :—| :—|
    • | category| String | Product category |
    • | functions| List | Instruction set |
    • | devices | List | device Id List |
  • Description of functions
    • | Parameter name | Category | Description |
    • | :—| :—| :—|
    • | code | String | Instruction |
    • | type | String | Instruction type |
    • | values | String | The range of input parameter values |
    • | name | String | Instruction name |
    • | desc | String | Description |

Request example

  1. GET /v1.0/ devices/functions?device_ids =06200286 dc4f22c8418c ,6c8b eb2f
  2. a517fbc901dtln

SDK example

  1. TuyaClient client = new TuyaClient(clientId , secret , RegionEnum.CN);
  2. categoryFunctions = client.getFunctionsByDevsList(DEV_ID);
  3. System.out.println(“Get the function list by devices List: “);
  4. System.out.println(JSONObject.toJSONString(category Functions));

Response example

tuya-Device-Control-Cloud-Services-API-Reference-Fig-
\(19\)

Error code
The following are common service exceptions for this interface. For more exception errors, see Error Code.

tuya-Device-Control-Cloud-Services-API-Reference-Fig-
\(20\)

Specifications and properties of the device

Get the specifications and properties of the device, including the instruction set and status set

API description
This interface is used to get the instruction set and status set supported by the device according to the device ID.

API address

  1. GET /v1.0/ devices /{ device_id }/ specifications

Request parameter

tuya-Device-Control-Cloud-Services-API-Reference-Fig-
\(21\)

Return parameter

tuya-Device-Control-Cloud-Services-API-Reference-Fig-
\(22\)tuya-Device-Control-Cloud-Services-
API-Reference-Fig- \(23\)

  • Description of result
    • | Parameter name | Category | Description |
    • | :—| :—| :—|
    • | category | String | Product category |
    • | functions | List | Instruction set |
    • | status | List | Status set |
  • Description of functions
    • | Parameter name | Category | Description |
    • | :—- | :—- | :—|
    • | code | String | command |
    • | type | String | Type |
    • | values | String | The range of parameter values |
  • Description of status
    • | Parameter name | Category | Description |
    • | :—| :—| :—|
    • | code | String | status code |
    • | type | String | Type |
    • | values | String | The range of parameter values |

Request example

  • GET /v1.0/ devices/vdevoXXXXXXXXXXXXXXX/specifications

SDK example
N/A

Return parameter

tuya-Device-Control-Cloud-Services-API-Reference-Fig-
\(24\) tuya-Device-Control-Cloud-Services-
API-Reference-Fig- \(25\)

Send instructions to the device

API description
This interface is used to send one or more obtained instruction sets. Whether instruction sets can be sent simultaneously depends on the product.

API address

  1. POST /v1.0/ devices /{ device_id }/ commands

Request parameter

tuya-Device-Control-Cloud-Services-API-Reference-Fig-
\(26\)

Return parameter

tuya-Device-Control-Cloud-Services-API-Reference-Fig-
\(27\)tuya-Device-Control-Cloud-Services-
API-Reference-Fig- \(28\)

Request example

  1. POST /v1.0/ devices/vdevo1552XXXX3954683/commands

tuya-Device-Control-Cloud-Services-API-Reference-Fig-
\(29\)

SDK example

tuya-Device-Control-Cloud-Services-API-Reference-Fig-
\(30\)

Response example

tuya-Device-Control-Cloud-Services-API-Reference-Fig-
\(31\)

Error code
The following are common service exceptions for this interface. For more exception errors, see Error Code.

tuya-Device-Control-Cloud-Services-API-Reference-Fig-
\(32\)

Get the latest device status

API description
Get the latest device status by the device ID

API address

  1. GET /v1.0/ devices /{ device_id }/ status

Request parameter

tuya-Device-Control-Cloud-Services-API-Reference-Fig-
\(33\)

Return parameter

tuya-Device-Control-Cloud-Services-API-Reference-Fig-
\(34\)tuya-Device-Control-Cloud-Services-
API-Reference-Fig- \(35\)

Request example

  1. GET /v1.0/ devices /{ device_id }/ status

SDK example

tuya-Device-Control-Cloud-Services-API-Reference-Fig-
\(36\)

Response example

tuya-Device-Control-Cloud-Services-API-Reference-Fig-
\(37\)tuya-Device-Control-Cloud-Services-
API-Reference-Fig- \(39\)

Error code
The following are common service exceptions for this interface. For more exception errors, see Error Code.

tuya-Device-Control-Cloud-Services-API-Reference-Fig-
\(38\)

Read User Manual Online (PDF format)

Read User Manual Online (PDF format)  >>

Download This Manual (PDF format)

Download this manual  >>

Related Manuals