在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称:TuyaAPI/cloud开源软件地址:https://github.com/TuyaAPI/cloud开源编程语言:JavaScript 100.0%开源软件介绍:tuyapi/cloudA NodeJS wrapper for Tuya's API. At the moment, only the mobile/app API (as captured by web.archive.org) is supported as it covers the vast majority of use cases. There are two modes of operation:
If you can, use the old API. Unfortunately, for some Step-by-step instructions for acquiring keys to use with the old API can be found here. Obtaining keys for new API (additional parameters Installation
Usageold API (register/login and create token): const Cloud = require('@tuyapi/cloud');
let api = new Cloud({key: 'your-api-app-key', secret: 'your-api-app-secret'});
api.register({email: '[email protected]', password: 'example-password'}).then(async sid => {
let token = await api.request({action: 'tuya.m.device.token.create', data: {'timeZone': '-05:00'}});
console.log(token) // => { secret: '0000', token: '01010101' }
}); new API (listing all devices in all groups): const Cloud = require('@tuyapi/cloud');
let api = new Cloud({key: apiKeys.key,
secret: apiKeys.secret,
secret2: apiKeys.secret2,
certSign: apiKeys.certSign,
apiEtVersion: '0.0.1',
region: 'EU'});
api.loginEx({email: myEmail, password: myPassword}).then(async sid => {
console.log(sid);
api.request({action: 'tuya.m.location.list'}).then(async groups => {
for (const group of groups) {
api.request({action: 'tuya.m.my.group.device.list', gid: group.groupId}).then(async devicesArr => {
for (const device of devicesArr) {
console.log('group: "%s"\tdevice: "%s"\tdevId: "%s"', group.name, device.name, device.devId);
}
});
}
});
}); Development
{
"key": "your-api-key",
"secret": "your-api-secret"
// for new API: add also secret2 and certSign
}
|
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论