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.
npm i @tuyapi/cloud
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' }
});- After cloning, run
npm i. - Add a file called
keys.jsonwith the contents
{
"key": "your-api-key",
"secret": "your-api-secret"
}- Create a file called
dev.jsas a playground. Sincedev.jsis 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.