Last Updated on : 2022-11-22 03:11:38download
This topic describes the request methods, endpoints, and request parameters that are used in API operations of the Tuya IoT Platform.
The API operations support the following request methods.
Method | Description |
---|---|
GET | Requests the server to return specified resources. |
PUT | Requests the server to update specified resources. |
POST | Requires the server to perform specified operations. |
DELETE | Requires the server to delete specified resources. |
When the request method POST is used, the Content-Type
parameter must be set to application/json
.
The platform provides a separate endpoint in a different region. You can select an endpoint of the region where your device is deployed. This allows you to reduce the response time of API requests.
Region | Endpoint |
---|---|
China Data Center | https://openapi.tuyacn.com |
Western America Data Center | https://openapi.tuyaus.com |
Eastern America Data Center | https://openapi-ueaz.tuyaus.com |
Central Europe Data Center | https://openapi.tuyaeu.com |
Western Europe Data Center | https://openapi-weaz.tuyaeu.com |
India Data Center | https://openapi.tuyain.com |
The following table lists common request parameters that are used in the API operations. You must set the values of the required parameters in the request headers.
Parameter | Type | Location | Required | Description |
---|---|---|---|---|
client_id |
String |
header | Yes | The user ID. |
sign | String | header | Yes | The signature that is generated by a specified signature algorithm. |
sign_method | String | header | Yes | The signature digest algorithm. Set the value to HMAC-SHA256 . |
t | Long | header | Yes | The 13-digit standard timestamp, which indicates the current time and date. |
access_token | String | header | Yes | The information about the token. Note: This parameter is not required when you make API requests to get or refresh tokens. |
lang | String | header | No | The type of language. Set the value to zh for the service that is deployed in mainland China and set the value to en for the service that is deployed in other regions outside mainland China. |
nonce | String | header | No | The universally unique identifier (UUID) automatically generated after an API is created.Note: This parameter is not required when you use the earlier signature solutions. |
Signature-Headers | String | header | No | The header field customized by you.Note: This parameter is not required when you use the earlier signature solutions. |
Take the API request to get the user list API as an example. With 50 entires returned on each page, get the information about the user list from 00:00:00, May 1, 2021 to 00:00:00, May 15, 2021. The request to get the first page of users is as follows:
API request
GET:https://openapi.tuyacn.com/v2.0/apps/schema/users?page_no=1&page_size=50&start_time=1619798400&end_time=1621008000
Request header
client_id: 1KAD46OrT9HafiKd****
sign: C5EFD19AD45E33A060C0BE47AEF65D975D54B2D70CBAA7A1ACA1A7D0E5C0****
sign_method: HMAC-SHA256
t: 1588925778000
access_token: 3f4eda2bdec17232f67c0b188af3****
nonce: 5138cc3a9033d69856923fd07b49****
Signature-Headers: area_id:request_id
area_id: 29a33e8796834b1**** // User-defined
request_id: 8afdb70ab2ed11eb85290242ac13****// User-defined
Is this page helpful?
YesFeedbackIs this page helpful?
YesFeedback