Quick Start

This guide is designed to help developers quickly understand how to create Apps and control devices through Tuya Cloud Platform to play smart. Let's start the application journey!

Prerequisites

Operating procedures

Tuya Smart Global Smart Platform

Apply for cloud API authorization

Follow-up device control depends on Access ID and Access Secret, please keep it safe!

Scan code authorization

You can use the "Graffiti Smart" APP scan code to connect to your project.

"Cloud Development" -> "Associated Device" -> "Associated Device under Tuya Smart App Account" image.png

image.png

Use Postman to simulate OpenApi to control the device

The App created through the Tuya cloud platform has a built-in Tuya SDK, which can control the device interactively with Tuya cloud platform. Next, we call OpenApi through Postman to simulate the control device.

        Set environment variable          - OpenApi settings        - Request method

        - Supported request methods are as follows:

             - GET - PUT - POST - DELETE              > Please note: When the request method is POST, Content-Type needs to useapplication / json         

    - Request header settings
    
    Any interface needs to add the following parameters to the header:
    
    |   Parameter  | Type | Parameter position | Description | Required |
    | ------------ | ------ | ------ | ---------------------------- | ---- |
    |  client_id  | String | header | client_id | Yes |
    |     sign | String | header | Signature calculated using the specified signature algorithm: token related interface, business related interface | Yes |
    | sign_method | String | header | Signature Digest Algorithm, HMAC-SHA256 | Yes |
    | t | Long | header | 13-bit standard timestamp | Yes |
    | lang | String | header | language, default en | No |

        
- Signature method

Tuya Cloud currently provides two sets of signature algorithms according to different application scenarios:

- Token related interface (v1.0 / token & v1.0 / token / {refresh_token}): sign = HMAC-SHA256 (client_id + t, secret) .toUpperCase ()
        
- Business interface (non-token interface): sign = HMAC-SHA256 (client_id + access_token + t, secret) .toUpperCase ()

FAQ

Q: How long is the token validity period?

Tuya: The token is valid for two hours and needs to be reapplied after it expires.

Q: What are clientId and secret and how do I get them?

Tuya: The clientId is the AccessId in the developer platform, and secret is the AccessKey in the developer platform.

Q: What is a schema and how to get it?

Tuya: The channel identifier of the App application, please obtain it based on the package name. For example, your App package name is: com.aa.bb, then your schema is: aabb.

Q: What is the data operation permission in the application scenario?

Tuya: In the application scenario, the device in the app, the developer has the operation permission.

Q: Why does the access interface encounter permission deny?

Tuya:

  1. Check whether the device has been removed;

  2. Whether the device is associated with the current developer clientId.

Concluding remarks

Through the above simple tutorial, I believe you have a general understanding of the capabilities provided by Tuya Cloud OpenAPI, and then you can code to implement Tuya Cloud API and carry out corresponding business development;

For more interfaces, please refer to the API interface list. If you have more customization requirements, please contact Tuya Business.

If you still have questions about the interface call, you can ask technical questions on the Tuya developer platform bill of lading. Before asking the questions, try to provide the interface request parameters.