{"id":27481,"library":"tuya-device-sharing-sdk","title":"Tuya Device Sharing SDK","description":"A Python SDK for Tuya Open API that provides IoT capabilities for device sharing, user management, and IoT core operations. Current version: 0.2.9. Maintained by Tuya official, with monthly releases.","status":"active","version":"0.2.9","language":"python","source_language":"en","source_url":"https://github.com/tuya/tuya-device-sharing-sdk","tags":["tuya","iot","device-sharing","smart-home","api-sdk"],"install":[{"cmd":"pip install tuya-device-sharing-sdk","lang":"bash","label":"Install from PyPI"}],"dependencies":[],"imports":[{"note":"The package exposes classes under the tuya_connector module, not the package name directly.","wrong":"from tuya_device_sharing_sdk import TuyaOpenAPI","symbol":"TuyaOpenAPI","correct":"from tuya_connector import TuyaOpenAPI"},{"note":"TuyaTokenInfo is a dataclass used for token storage.","wrong":"","symbol":"TuyaTokenInfo","correct":"from tuya_connector import TuyaTokenInfo"},{"note":"Used for message queue connections.","wrong":"","symbol":"TuyaOpenMQ","correct":"from tuya_connector import TuyaOpenMQ"}],"quickstart":{"code":"import os\nfrom tuya_connector import TuyaOpenAPI\n\nACCESS_ID = os.environ.get('TUYA_ACCESS_ID', '')\nACCESS_KEY = os.environ.get('TUYA_ACCESS_KEY', '')\nAPI_ENDPOINT = 'https://openapi.tuyaus.com'\n\nopenapi = TuyaOpenAPI(API_ENDPOINT, ACCESS_ID, ACCESS_KEY)\nopenapi.connect()\nprint('Connected' if openapi.token else 'Connection failed')","lang":"python","description":"Initialize TuyaOpenAPI with credentials from environment variables and test connection."},"warnings":[{"fix":"Use 'from tuya_connector import TuyaOpenAPI' instead of 'from tuya_device_sharing_sdk import ...'","message":"The package provides a 'tuya_connector' module, not a top-level 'tuya_device_sharing_sdk' module. Import from tuya_connector.","severity":"gotcha","affected_versions":"all"},{"fix":"Ensure API_ENDPOINT is set to the correct regional endpoint.","message":"API endpoint must match the region of your Tuya IoT account. Common endpoints: https://openapi.tuyaus.com (US), https://openapi.tuyacn.com (China), https://openapi.tuyaeu.com (Europe).","severity":"gotcha","affected_versions":"all"},{"fix":"Change imports to use 'from tuya_connector import ...'","message":"The older pattern of importing from 'tuya_device_sharing_sdk' directly is deprecated. Only import from 'tuya_connector' is supported in v0.2.x.","severity":"deprecated","affected_versions":">=0.2.0"},{"fix":"Check token expiry and call openapi.connect() again if needed.","message":"Token expiration is not automatically refreshed in the SDK. You must handle token refresh logic yourself or re-connect on 401 errors.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Use 'from tuya_connector import TuyaOpenAPI'","cause":"Attempting to import from the package name directly instead of tuya_connector.","error":"ModuleNotFoundError: No module named 'tuya_device_sharing_sdk'"},{"fix":"Verify the API_ENDPOINT matches your Tuya region and that your credentials are correct.","cause":"Incorrect API endpoint or network issue.","error":"tuya_connector.exceptions.TuyaConnectionException: Connection failed"},{"fix":"Call openapi.connect() again with valid ACCESS_ID and ACCESS_KEY.","cause":"Token expired or credentials incorrect.","error":"invalid_grant: The access token or refresh token is invalid"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}