Last Updated on : 2024-06-21 07:11:07download
The Tuya Developer Platform provides API Explorer for you to debug the APIs quickly. Also, you can use Postman to make API requests. For example, Postman can be used to get device information or control devices. This topic describes how to set the Postman environment variables that are used in the API operations of the Developer Platform. It also describes the procedure to call these API operations.
Install the desktop client Postman with 8.2.2
or later version.
An early version will cause incompatibility with the Tuya API Package. Please upgrade to the recommended version or later.
Click Workspace in the top-left corner of the page to select a workspace, and choose Import > Upload Files to import the API Package and API Environment Package.
If an earlier version of signature verification is used, you can download Tuya OpenAPI Package—Earlier Version.
Set Postman environment variables.
In the left-side navigation pane, click Environments and double-click API environment package to set the parameters. Save the settings, click Set active, and then confirm that the No Environment in the top-right corner of the page is changed to API environment package.
Parameter |
Description |
---|---|
url |
The endpoint of the Tuya Cloud service that you want to manage.Note: For example, the endpoint of the Tuya Cloud service that is deployed in mainland China is set to |
client_id |
The username that is authorized to access the specified cloud development project. The value is the same as the value of the accessId parameter on the platform. For more information, see Manage Authorization. |
secret |
The password for the username. The value is the same as the value of the accessKey parameter on the platform. For more information, see Manage Authorization. |
device_id (optional) |
The device ID. You can view the information about the device in the app.Note: Click the device that is added to the app and click the pencil icon in the top right corner of the page to view the device ID in the Device Information section. |
schema (optional) |
The channel identifier of the app. Set the value based on the app package name.Note: For example, if your app package name is |
Fill in the values in CURRENT VALUE column.
Get a token.
Call the Get access_token with simple mode operation to get the value of access_token. The value is required when you call API operations to control devices.
Call the Query instructions sets supported by the device operation to get the data points supported by the device. You can use them to control the device.
Call the Send device commands operation to control the device.
You can send a command that is supported by the device to achieve the required effect.
The following code block in the API request body shows how to start a robot vacuum:
{
"commands":[
{
"code": "power",
"value":true
}
]
}
The robot vacuum is started to run as expected.
Is this page helpful?
YesFeedbackIs this page helpful?
YesFeedback