{"id":19858461,"url":"https://github.com/tuya/tuya-cloud-sdk-nodejs","last_synced_at":"2025-05-02T02:31:01.335Z","repository":{"id":103228344,"uuid":"312223357","full_name":"tuya/tuya-cloud-sdk-nodejs","owner":"tuya","description":"Tuya Cloud API SDK for node.js","archived":false,"fork":false,"pushed_at":"2021-02-20T06:51:26.000Z","size":39,"stargazers_count":10,"open_issues_count":3,"forks_count":5,"subscribers_count":13,"default_branch":"main","last_synced_at":"2025-04-06T21:24:32.840Z","etag":null,"topics":["tuya"],"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/tuya.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"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,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-11-12T09:10:29.000Z","updated_at":"2023-08-31T13:36:23.000Z","dependencies_parsed_at":null,"dependency_job_id":"c20c9e94-cee0-4fbc-a5c1-b9520382ea6a","html_url":"https://github.com/tuya/tuya-cloud-sdk-nodejs","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tuya%2Ftuya-cloud-sdk-nodejs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tuya%2Ftuya-cloud-sdk-nodejs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tuya%2Ftuya-cloud-sdk-nodejs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tuya%2Ftuya-cloud-sdk-nodejs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tuya","download_url":"https://codeload.github.com/tuya/tuya-cloud-sdk-nodejs/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251972459,"owners_count":21673610,"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":["tuya"],"created_at":"2024-11-12T14:23:33.295Z","updated_at":"2025-05-02T02:31:01.330Z","avatar_url":"https://github.com/tuya.png","language":"JavaScript","readme":"# Tuya Cloud API SDK for  Nodejs\n\n[English](README.md) | [中文版](README_cn.md)\n\n## Introduction\n\nTuya Cloud API SDK for Nodejs\n\n## Preparation\n- Make sure that the Nodejs version is 7.10.1 and above.\n\n- Register a developer account on the Tuya Cloud platform and determine the values of `AccessID, AccessKey, Endpoint` (calling address)\n\n## Source installation\n1. Unzip the source code package to a suitable location for your project.\n2. You can refer to the example and quote the corresponding module code in the code.\n\n## Example\n\nBefore you run the SDK, explicitly initialize the developer information:\n```\n   Config.init(accessID, accessKey, Region.URL_CN);\n```\n\nTake the device information interface as an example, directly call device.GetDevice():  \n```nodejs\n    \n    let deviceId = 'xxxx';\n    let callback = function(err, data) {\n        if (err) {\n            console.log(err);\n            return;\n        }\n    \n        console.log(data);\n    };\n    \n    // Get device information\n    DeviceClient.getDevice(deviceId, callback);\n    \n```\n\n## Currently supported API\n\n| Module | Request Class |\n| ---- | ---- |\n| Token related | TokenClient |\n| User management | UserClient |\n| Device management | DeviceClient |\n| Device control | DeviceControlClient |\n| Device group | DeviceGroupClient |\n| Device member management | DeviceMemberClient |\n| Statistics | DataClient |\n| Family management | HomeClient |\n| Automation | AutomationClient |\n| Scene | SceneClient |\n| Distribution network management | PairTokenClient |\n| Timing management | TimeClient |\n| Weather management | WeatherClient |\n\n\n\n## FAQ\n\n### About refreshToken interface\n\n\u003e **Note**: The refreshToken interface will return a new access_token, even if the old token has not expired.\n\nThis logic is already done in the `GetToken` method, and users generally do not need to call the refresh interface.\n\n### Do I need to get the token or refresh the token before calling the API?\n\nNo, this layer of logic has been implemented in the  API method. The token information will be cached in memory.\n\n### When calling an interface, if the token has expired, do I need to manually call the refresh-token interface?\n\nNo, in the `GetToken()` method implementation, it will check whether the token has expired. If it expires, it will be pulled again.\n\n### If your token will be refreshed in multiple nodes, then you need to implement common.TokenLocalManage interface yourself\nThe Tuya’s cloud token only guarantees that there will be no problems in refreshing the targeted user level, but the concurrent refresh of a user’s token on multiple nodes will cause only one node to be successful and others to be failed.\nBecause the `get token` interface will return access_token and refresh_token, but the `refresh token` interface will erase the current refresh_token, and a new one will be invalidated.\n\n### How to deal with the exception information and error of the API method?\n\nIf the interface returns an error, it can generally be a url error or a json parsing error, you can contact Tuya related staff to help modify.\n\nIf the error is empty, but the `success` field of `response` is false, the developer can check according to the detailed error information in the `Msg` field.\n\n### In the interface for getting device list, if there are multiple deviceIDs, how to splice it?\n\nMultiple deviceIDs, separated by English commas\n\n### In the interface for obtaining user list, what does schema refer to?\n\nAfter creating the APP-SDK, the channel identifier of the detail page is the schema.\n\n### what does pair_token mean in `v1.0/devices/tokens/{{pair_token}}` interface? How to get it?\n\nPair_token refers to the network token of a user under the app, which can be obtained from v1.0/devices/token.\n\n### If the API in the SDK is not updated in time, how to implement an API?\n\nThere are three methods:\n\n- Custom class implementation\n    1. If the request does not need to pass the body parameter, create a request class to inherit com.tuya.api.common.ApiRequest, and improve the two methods of getRequestMethod and getRequestUrl.\n    If the interface needs to pass body parameters, it should inherit com.tuya.api.common.ApiRequestBody, and improve the getRequestMethod, getRequestUrl and getRequestBody methods;\n\n    2. Expose the request method through the client class.\n\n    \u003e For details, please refer to the relevant examples in the example.user/example.device directory.\n\n- Use the provided general interface\n    Call CommonClient directly and pass in the corresponding parameters.\n\n    \u003e For details, please refer to the relevant examples in the example.common directory.\n\n- Please submit an issue, and we will update it in time ^_^\n## Support\n\nYou can get support from Tuya with the following methods:\n\n- Tuya Smart Help Center: [https://support.tuya.com/en/help](https://support.tuya.com/en/help)\n- Technical Support Council: [https://iot.tuya.com/council](https://iot.tuya.com/council)\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftuya%2Ftuya-cloud-sdk-nodejs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftuya%2Ftuya-cloud-sdk-nodejs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftuya%2Ftuya-cloud-sdk-nodejs/lists"}