Skip to main content

The `tuya-connector-python` SDK is desinged to support open APIs and Pulsar Messages provided by Tuya.

Project description

tuya-connector-python

PyPI

PyPI - Downloads

PyPI - Python Version

The tuya-connector-python SDK is designed to support openAPIs and Pulsar messages provided by Tuya. Before using this SDK, you can see Quick Start on the Tuya Developer website to learn more about Cloud Development Platform.

Install

pip3 install tuya-connector-python

Get started

  1. Sign up for Tuya developer account.

  2. Create a cloud project. See the tutorial for how to get the authorization key and other necessary parameters.

  3. A quick example is as follows:

    from tuya_connector import (
    	TuyaOpenAPI,
    	TuyaOpenPulsar,
    	TuyaCloudPulsarTopic,
    )
    
    ACCESS_ID = "your-access-id"
    ACCESS_KEY = "your-access-key"
    API_ENDPOINT = "https://openapi.tuyacn.com"
    MQ_ENDPOINT = "wss://mqe.tuyacn.com:8285/"
    
    # Init OpenAPI and connect
    openapi = TuyaOpenAPI(API_ENDPOINT, ACCESS_ID, ACCESS_KEY)
    openapi.connect()
    
    # Call any API from Tuya
    response = openapi.get("/v1.0/statistics-datas-survey", dict())
    
    # Init Message Queue
    open_pulsar = TuyaOpenPulsar(
    	ACCESS_ID, ACCESS_KEY, MQ_ENDPOINT, TuyaCloudPulsarTopic.PROD
    )
    # Add Message Queue listener
    open_pulsar.add_message_listener(lambda msg: print(f"---\nexample receive: {msg}"))
    
    # Start Message Queue
    open_pulsar.start()
    
    input()
    # Stop Message Queue
    open_pulsar.stop()
    

OpenAPI reference

Tuya opens up a variety of APIs covering scenarios such as device pairing, asset management, and device control. You can call APIs according to API reference to create IoT applications.

Feedback

If you have any questions, please provide feedback via Github Issue or Technical Ticket.

License

The tuya-connector-python SDK is available under the MIT license. For more information, see the LICENSE file.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tuya-connector-python-0.1.2.tar.gz (9.1 kB view hashes)

Uploaded Source

Built Distribution

tuya_connector_python-0.1.2-py3-none-any.whl (9.9 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page