{"id":21927772,"url":"https://github.com/tuyaapi/cloud","last_synced_at":"2025-04-19T17:34:13.880Z","repository":{"id":40444090,"uuid":"134298025","full_name":"TuyaAPI/cloud","owner":"TuyaAPI","description":"🌨 🎁 A NodeJS wrapper for Tuya's cloud API. Documentation: https://tuyaapi.github.io/cloud/.","archived":false,"fork":false,"pushed_at":"2023-12-15T05:28:24.000Z","size":3927,"stargazers_count":37,"open_issues_count":3,"forks_count":18,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-13T02:47:51.597Z","etag":null,"topics":["cloud","iot","nodejs"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/TuyaAPI.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null},"funding":{"github":["codetheweb"],"patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":null}},"created_at":"2018-05-21T16:50:06.000Z","updated_at":"2025-01-04T19:48:49.000Z","dependencies_parsed_at":"2023-12-15T06:44:43.853Z","dependency_job_id":null,"html_url":"https://github.com/TuyaAPI/cloud","commit_stats":{"total_commits":59,"total_committers":9,"mean_commits":6.555555555555555,"dds":0.6271186440677966,"last_synced_commit":"b7dc1256c0eb5756f00000949e88424db59b568e"},"previous_names":[],"tags_count":20,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TuyaAPI%2Fcloud","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TuyaAPI%2Fcloud/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TuyaAPI%2Fcloud/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TuyaAPI%2Fcloud/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/TuyaAPI","download_url":"https://codeload.github.com/TuyaAPI/cloud/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249750229,"owners_count":21320102,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cloud","iot","nodejs"],"created_at":"2024-11-28T22:17:33.091Z","updated_at":"2025-04-19T17:34:13.863Z","avatar_url":"https://github.com/TuyaAPI.png","language":"JavaScript","readme":"tuyapi/cloud [![Build Status](https://travis-ci.org/TuyaAPI/cloud.svg?branch=master)](https://travis-ci.org/TuyaAPI/cloud) [![Coverage Status](https://coveralls.io/repos/github/TuyaAPI/cloud/badge.svg?branch=master)](https://coveralls.io/github/TuyaAPI/cloud?branch=master) [![XO code style](https://img.shields.io/badge/code_style-XO-5ed9c7.svg)](https://github.com/xojs/xo)\n==============\n\nA NodeJS wrapper for Tuya's [API](https://docs.tuya.com/en/cloudapi/appAPI/index.html).\n\nAt the moment, only the [mobile/app API](https://web.archive.org/web/20180613132925/https://docs.tuya.com/en/cloudapi/appAPI/index.html) (as captured by web.archive.org) is supported as it covers the vast majority of use cases.\n\nThere are two modes of operation:\n- the 'old' API - described in the docs, using MD5 as a sign mechanism\n- the 'new' API - reverse-engineered from the TuyaSmart Android app, using HMAC-SHA256 as a sign mechanism\n\nIf you can, use the old API.  Unfortunately, for some `clientId/key`'s you must use the new API (eg. clientId used by TuyaSmart app). To use the the new API, specify `apiEtVersion` as an option in constructor (currently `'0.0.1'`).\n\nStep-by-step instructions for acquiring keys to use with the old API can be found [here](https://tuyaapi.github.io/cloud/apikeys/).\n\nObtaining keys for new API (additional parameters `secret2` and `certSign` are required) involves disassembling obtained an APK file (either official app or generated \"demo\" app from iot.tuya.com). For details see [tuya-sign-hacking repo](https://github.com/nalajcie/tuya-sign-hacking).\n\n## Installation\n`npm i @tuyapi/cloud`\n\n## Usage\nold API (register/login and create token):\n```javascript\nconst Cloud = require('@tuyapi/cloud');\n\nlet api = new Cloud({key: 'your-api-app-key', secret: 'your-api-app-secret'});\n\napi.register({email: 'example@example.com', password: 'example-password'}).then(async sid =\u003e {\n  let token = await api.request({action: 'tuya.m.device.token.create', data: {'timeZone': '-05:00'}});\n\n  console.log(token) // =\u003e { secret: '0000', token: '01010101' }\n});\n```\n\nnew API (listing all devices in all groups):\n```javascript\nconst Cloud = require('@tuyapi/cloud');\n\nlet api = new Cloud({key: apiKeys.key,\n                     secret: apiKeys.secret,\n                     secret2: apiKeys.secret2,\n                     certSign: apiKeys.certSign,\n                     apiEtVersion: '0.0.1',\n                     region: 'EU'});\n\napi.loginEx({email: myEmail, password: myPassword}).then(async sid =\u003e {\n  console.log(sid);\n\n  api.request({action: 'tuya.m.location.list'}).then(async groups =\u003e {\n    for (const group of groups) {\n      api.request({action: 'tuya.m.my.group.device.list', gid: group.groupId}).then(async devicesArr =\u003e {\n        for (const device of devicesArr) {\n           console.log('group: \"%s\"\\tdevice: \"%s\"\\tdevId: \"%s\"', group.name, device.name, device.devId);\n        }\n      });\n    }\n  });\n});\n```\n\n[Documentation](https://tuyaapi.github.io/cloud/)\n\n## Development\n1. After cloning, run `npm i`.\n2. Add a file called `keys.json` with the contents\n```javascript\n{\n  \"key\": \"your-api-key\",\n  \"secret\": \"your-api-secret\"\n  // for new API: add also secret2 and certSign\n}\n```\n3. Create a file called `dev.js` as a playground. Since `dev.js` is in `.gitignore`, it won't be committed.\n4. To run tests, run `npm test`.\n5. To output coverage, run `npm run cover` (it will exit with an error).\n6. To build documentation, run `npm run document`.\n\n[![forthebadge](https://forthebadge.com/images/badges/made-with-javascript.svg)](https://forthebadge.com)\n","funding_links":["https://github.com/sponsors/codetheweb"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftuyaapi%2Fcloud","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftuyaapi%2Fcloud","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftuyaapi%2Fcloud/lists"}