tuyapi/cloud
A NodeJS wrapper for Tuya's API.
At the moment, only the mobile/app API is supported as it covers the vast majority of use cases.
Step-by-step instructions for acquiring API keys can be found here.
Installation
npm i @tuyapi/cloud
Usage
const Cloud = require('@tuyapi/cloud');
let api = new Cloud({key: 'your-api-app-key', secret: 'your-api-app-secret'});
api.register({email: 'example@example.com', 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' }
});
Development
- After cloning, run
npm i
. - Add a file called
keys.json
with the contents
{
"key": "your-api-key",
"secret": "your-api-secret"
}
- Create a file called
dev.js
as a playground. Sincedev.js
is in.gitignore
, it won't be committed. - To run tests, run
npm test
. - To output coverage, run
npm run cover
(it will exit with an error). - To build documentation, run
npm run document
.