{"id":19858295,"url":"https://github.com/tuya/tuya-cloud-sdk-go","last_synced_at":"2025-10-27T15:44:38.063Z","repository":{"id":45503972,"uuid":"312217795","full_name":"tuya/tuya-cloud-sdk-go","owner":"tuya","description":"Tuya Cloud API SDK for go","archived":false,"fork":false,"pushed_at":"2024-01-03T08:30:20.000Z","size":7384,"stargazers_count":18,"open_issues_count":6,"forks_count":14,"subscribers_count":10,"default_branch":"main","last_synced_at":"2025-04-06T21:22:32.808Z","etag":null,"topics":["tuya"],"latest_commit_sha":null,"homepage":"","language":"Go","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-12T08:47:19.000Z","updated_at":"2024-10-24T03:56:21.000Z","dependencies_parsed_at":"2024-06-19T00:15:13.514Z","dependency_job_id":null,"html_url":"https://github.com/tuya/tuya-cloud-sdk-go","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-go","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tuya%2Ftuya-cloud-sdk-go/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tuya%2Ftuya-cloud-sdk-go/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tuya%2Ftuya-cloud-sdk-go/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tuya","download_url":"https://codeload.github.com/tuya/tuya-cloud-sdk-go/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251972450,"owners_count":21673607,"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:22:45.875Z","updated_at":"2025-10-27T15:44:33.030Z","avatar_url":"https://github.com/tuya.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Tuya Cloud API SDK for Golang\n\n[English](README.md) | [中文版](README_cn.md)\n\n## Introduction\n\nTuya Cloud API SDK for Golang.\n\n## Get Started\n\nMake sure you have `serverHOST`, `AccessID` and `AccessKey`.\n\nBefore running this SDK, you need to initialize it with the following method:\n\n```\nconfig.SetEnv(common.URLCN, \"AccessID\", \"AccessKey\")\n```\n\n**Example**\n\nIf you want to fetch the device info, you can call `device.GetDevice()`:\n\n```\ndeviceID := \"xxx\"\ngot, err := device.GetDevice(deviceID)\nif err!=nil{\n    xxx\n}\n// process got\n```\n\n## Supported API\n\n|  Method                   | API                                               | Description  |\n|  ----                     | ----                                              | ----  |\n| token.GetTokenAPI         | GET /v1.0/token?grant_type=1                     | [Get access_token with simple method](https://developer.tuya.com/en/docs/iot/open-api/api-reference/authorization/oauth-management) |\n| token.RefreshToken     | GET /v1.0/token/{easy_refresh_token}           | [Refresh token](https://developer.tuya.com/en/docs/iot/open-api/api-reference/authorization/oauth-management) |\n| device.GetDevice          | GET /v1.0/devices/{device_id}                  | [Get device details](https://developer.tuya.com/en/docs/iot/open-api/api-reference/smart-home-devices-management/device-management) |\n| device.GetDeviceFunctions | GET /v1.0/devices/{deviceId}/functions | [Get function list](https://developer.tuya.com/en/docs/iot/open-api/api-reference/smart-home-devices-management/device-control) |\n| device.GetDeviceFunctionByCategory | GET /v1.0/functions/{category} | [Get function list by category](https://developer.tuya.com/en/docs/iot/open-api/api-reference/smart-home-devices-management/device-control) |\n| device.GetDeviceStatus | GET /v1.0/devices/{device_id}/status           | [Get device data point details](https://developer.tuya.com/en/docs/iot/open-api/api-reference/smart-home-devices-management/device-control) |\n| device.PostDeviceCommand | POST /v1.0/devices/{device_id}/commands       | [Send device command](https://developer.tuya.com/en/docs/iot/open-api/api-reference/smart-home-devices-management/device-control) |\n| device.DeleteDevice | DELETE /v1.0/devices/{device_id} | [Remove device](https://developer.tuya.com/en/docs/iot/open-api/api-reference/smart-home-devices-management/device-management) |\n| user.PostUserRegister   | POST /v1.0/apps/{schema}/user | [User registration](https://developer.tuya.com/en/docs/iot/open-api/api-reference/smart-home-family-management/user-management) |\n| user.GetDeviceListByUid | GET /v1.0/users/{uid}/devices | [Get deice list by user ID   ](https://developer.tuya.com/en/docs/iot/open-api/api-reference/smart-home-devices-management/device-management) |\n| device.dn.GetDevicesByToken | POST /v1.0/device/paring/token         | [Generate pairing token](https://developer.tuya.com/en/docs/iot/open-api/api-reference/smart-home-devices-management/paring-management) |\n\n\n## FAQ\n\n### About refreshToken interface\n\nNote: The `refreshToken` interface will return a new `access_token`, even if the old token has not expired.\n\nThis logic is already implemented in the `GetToken` method, and generally you do not need to call the `refreshToken` interface.\n\n### Do I need to get the token or refresh the token before calling the API?\n\nNo, this 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, it will check whether the token has expired. If token expires, it will be pulled again.\n\n### If a token is refreshed in multiple nodes, then you need to implement `common.TokenLocalManage` interface \n\nTuya's cloud token only guarantees that refreshing problems will not occur on the end-users side, but if the token of one user refreshes concurrently on multiple nodes, it will cause one node to be successful while other nodes fail. `GetToken` interface will return an `access_token` and `refresh_token`, but `refresh_token` interface will erase the current `refresh_token` and generate a new token, so the old token will be invalid.\n\n### How to deal with the exception 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 technical staff for help.\n\nIf error is empty, but the success field of the response is false, you can troubleshoot according to the detailed error information in the `Msg` field.\n\n### Get the device list interface, if there are multiple deviceIDs, how to splice it?\n\nMultiple deviceIDs, separated by commas.\n\n### In the interface for obtaining user list, what does schema refer to?\n\nAfter creating the App SDK, the channel ID on the detail page is the schema.\n\n### `v1.0/devices/tokens/{{pair_token}}` interface, what does `pair_token` mean? How to get it?\n\n`Pair_token` refers to the network pairing token of an app user, 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 two ways:\n\n1. You can implement the `common.APIRequest` interface. If it is a POST request, you need to also implement the `RequestBody` interface. Then call `DoAPIRequest()`. For more information, see `UserDevicesAPI`.\n2. Submit an issue, and we will handle the update.\n\n\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: [https://iot.tuya.com/council](https://iot.tuya.com/council)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftuya%2Ftuya-cloud-sdk-go","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftuya%2Ftuya-cloud-sdk-go","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftuya%2Ftuya-cloud-sdk-go/lists"}