/cloud

🌨 🎁 A NodeJS wrapper for Tuya's cloud API. Documentation: https://tuyaapi.github.io/cloud/.

Primary LanguageJavaScriptMIT LicenseMIT

tuyapi/cloud Build Status Coverage Status XO code style

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' }
});

Documentation

Development

  1. After cloning, run npm i.
  2. Add a file called keys.json with the contents
{
  "key": "your-api-key",
  "secret": "your-api-secret"
}
  1. Create a file called dev.js as a playground. Since dev.js is in .gitignore, it won't be committed.
  2. To run tests, run npm test.
  3. To output coverage, run npm run cover (it will exit with an error).
  4. To build documentation, run npm run document.

forthebadge