Debug APIs with API Explorer

Last Updated on : 2024-06-20 07:09:53download

This topic describes how to subscribe to device control API products, and use API Explorer to check API calls and troubleshoot issues on the Cloud page of the Tuya Developer Platform.

Prerequisites

A sub-device is added to Tuya Edge Gateway (TEdge). For more information, see Manage Devices on Tuya Edge Gateway.

Procedure

  1. Choose API Products > Industry Project and subscribe to Industrial General Device Control. For more information, see Manage API Products.

  2. Choose Subscribed Products > Industrial General Device Control > Authorized Projects (Authorize) > New Authorization, and select your project in the dialog box that appears.

  3. Choose Cloud > API Explorer and send control commands. For more information, see API Explorer.

  4. Send control commands with API Explorer.

    • Choose API Explorer > Control Device and set the device_id field. You can get the value of device_id on the Sub-devices page of Tuya Edge Gateway.
    • Set the commands field. The following code block shows the sample code:
      [
      	{"code":"switch_1","value":true},
      	{"code":"countdown_1","value":318}
      ]
      
  5. View device logs.

    Go to the Log query page of the platform and enter the device ID to view device logs.

    Debug APIs with API Explorer

  6. View sub-device status.

    At the edge gateway, you can view the latest status of the sub-device for the edge gateway.

    Debug APIs with API Explorer