Code Monkey home page Code Monkey logo

tuya-connector-python's Introduction

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.

tuya-connector-python's People

Contributors

crabbykang avatar funnybunnyqaq avatar makhalin avatar tsutsuku avatar vincent770 avatar zlinoliver avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.