Last Updated on : 2023-12-07 03:33:44download
This topic describes the APIs of synchronizing users, getting the user list, and getting user information.
Request method | API | Description |
---|---|---|
POST | /v1.0/apps/{schema}/user | Synchronize users |
GET | /v2.0/apps/{schema}/users | Get the user list |
GET | /v1.0/users/{uid}/infos | Get user information |
It is the account synchronization interface. You can create accounts and modify account information by different parameters according to your scenarios.
POST /v1.0/apps/{schema}/user
Parameter name | Data type | Parameter type | Required | Description |
---|---|---|---|---|
schema | String | URI | Yes | The unique identifier of an application, which corresponds to the identifier in the application management of the IoT Platform. |
country_code | String | body | Yes | Country code. |
username | String | body | Yes | Username. |
Password | String | body | Yes | The user password. We recommend that you use the MD5 Hash password. |
username_type | Integer | body | Yes | The type of username.
|
nick_name | String | body | No | Nickname. |
time_zone_id | String | body | No | Time zone id. |
Parameter name | Data type | Description |
---|---|---|
code | Integer | Error code. |
success | Boolean | Determine whether the request succeeded or not. true: succeeded false: failed |
msg | String | The message returned if the request fails. It will return null if the request succeeds. |
result | Object<result> | The returned result. |
Description of result
Parameter name | Data type | Description |
---|---|---|
uid | String | The Tuya user ID. |
POST /v1.0/apps/testApp/user
{
"country_code":"86",
"username":"182*****678",
"password":"c7fb2740c5f******4ed765a479fa",
"username_type":1,
"time_zone_id": "Asia/Shanghai"
}
Java SDK example
TuyaClient client = new TuyaClient(clientId, secret, RegionEnum.CN);
String uid = client.registerUser("testApp","86","182*****678",MD5Util.getMD5("123456")"nickName",UserTypeEnum.MOBLIE);
System.out.println("User synchronization succeeded: "+uid);
{
"success": true,
"result": {
"uid": "ay1534*****4744oIAa"
}
}
The following are common service exceptions for this interface. For more exception errors, see Error Code.
Error code | Description |
---|---|
500 | System error |
1106 | Illegal permission. Confirm whether the application schema is correct. |
2403 | The country code is not supported. Confirm whether it is in the current data center. |
2021 | Invalid mobile phone number. When the type of username is set to 1 , the mobile phone number format is incorrect. |
2022 | Invalid email address. When the type of username is set to 2 , the email address format is incorrect. |
GET /v2.0/apps/{schema}/users
Parameter name | Data type | Parameter type | Required | Description |
---|---|---|---|---|
schema | String | URI | Yes | App schme |
page_no | Int | URL | Yes | The current page number |
page_size | Int | URL | Yes | Page size. The value range is 0–100. |
start_time | Long | URL | Yes | Start time, 10-digit timestamp. |
end_time | Long | URL | Yes | End time, 10-digit timestamp. |
Parameter name | Data type | Description |
---|---|---|
code | Integer | Error code. |
success | Boolean | Determine whether the request succeeded or not. true: succeeded false: failed |
msg | String | The message returned if the request fails. It will return null if the request succeeds. |
result | Object<result> | User information |
Description of result
Parameter name | Data type | Description |
---|---|---|
list | Object | See Description of list |
has_more | Boolean | Determine whether there is more user data. true: yes false: no |
total | Integer | The total number of users in the Schema. |
Description of list
Parameter name | Data type | Description |
---|---|---|
uid | String | User ID |
username | String | Username |
mobile | String | The mobile phone number which returns for users registered by a mobile phone number. |
String | The email address which returns for users registered by a email address. |
GET /v2.0/apps/testapp/users?page_no=1&page_size=10&start_time=1602848780&end_time=1603809946
Java SDK example
TuyaClient client = new TuyaClient(clientId, secret, RegionEnum.CN);
UserList result = client.getUsers("testApp",1,10);
System.out.println("Get the user list: ");
System.out.println(JSONObject.toJSONString(result));
{
"success":true,
"t":1551851043862,
"result":{
"list":[
{
"country_code":"86",
"uid":"ay15264******aK4Jo",
"username":"****",
"mobile":"****"
},
{
"country_code":"86",
"uid":"ay1526******09hBOKe",
"username":"****",
"email":"****"
}
],
"has_more":false,
"total":12
}
}
The following are common service exceptions for this interface. For more exception errors, see Error Code.
Error code | Description |
---|---|
500 | System error |
1003 | Invalid grant type |
1107 | Invalid code |
This interface is used to get user information.
GET /v1.0/users/{uid}/infos
Parameter name | Data type | Parameter type | Required | Description |
---|---|---|---|---|
uid | String | URI | Yes | User ID |
Parameter name | Data type | Description |
---|---|---|
code | Integer | Error code. |
success | Boolean | Determine whether the request succeeded or not. true: succeeded false: failed |
msg | String | The message returned if the request fails. It will return null if the request succeeds. |
result | Object<result> | User information |
Description of result
Parameter name | Data type | Description |
---|---|---|
country_code | String | Country code |
avatar | String | Avatar |
mobile | String | Phone |
nick_name | String | Nickname |
uid | String | User ID |
username | String | Username |
create_time | Long | Creation time |
update_time | Long | Update time |
GET /v1.0/users/ay876543456789/infos
{
"result": {
"avatar": "",
"create_time": 1582601946,
"mobile": "86-153******93",
"nick_name": "",
"uid": "ay1587******2vqTA",
"update_time": 1582601946,
"username": "86-153******93"
},
"success": true,
"t": 1586153261345
}
The following are common service exceptions for this interface. For more exception errors, see Error Code.
Error code | Description |
---|---|
500 | System error |
Is this page helpful?
YesFeedbackIs this page helpful?
YesFeedback