Skip to main content

A Python SDK for Masrobo RCS OPEN API

Project description

Open Python SDK

Open Python SDK is a lightweight Python client for the Boticz Open API.

Features

  • X-Token authentication using JWT tokens generated from app_id and app_key using JWT tokens generated from app_id and app_key
  • Unified HTTP client and error handling
  • IoT device APIs
    • Get latest device data
    • Send device command
    • Bind device
    • Update device settings

如何使用

安装

pip3 install masrobo_rcs_sdk

Quick Start

from masrobo_rcs_sdk import RobotController, TopicDeviceData, GetLatestDeviceDataRequest

client = RobotController(
    base_url="https://api.boticz.cn/open",
    app_id="your-app-id",
    app_key="your-app-key",
)

resp = client.IotDevice.get_latest_device_data(
    GetLatestDeviceDataRequest(
        product_name="demo_product",
        device_id="device001",
        topic_name=TopicDeviceData,
    )
)

print(resp)

Available APIs

Get latest device data

from masrobo_rcs_sdk import TopicScreenshot, GetLatestDeviceDataRequest

client.IotDevice.get_latest_device_data(
    GetLatestDeviceDataRequest(
        product_name="demo_product",
        device_id="device001",
        topic_name=TopicScreenshot,
    )
)

Send device command

from masrobo_rcs_sdk import TopicRemoteControl, SendDeviceCommandRequest

client.IotDevice.send_device_command(
    SendDeviceCommandRequest(
        command="reboot",
        parameter='{"delay":1}',
        device_id="device001",
        product_name="demo_product",
        topic_name=TopicRemoteControl,
    )
)

Bind device

from masrobo_rcs_sdk import BindDeviceRequest

client.IotDevice.bind_device(BindDeviceRequest(device_id="device001"))

Update device settings

from masrobo_rcs_sdk import DeviceSettingRequest

client.IotDevice.setting(
    DeviceSettingRequest(
        device_id="device001",
        settings='{"temperature":{"max_value":30,"min_value":10,"calibration":0},"humidity":{"max_value":80,"min_value":20,"calibration":0},"data_recording_interval":5,"reporting_interval":10,"alert_interval":15,"alert_battery":10}',
    )
)

Error Handling

from masrobo_rcs_sdk import APIError

try:
    client.IotDevice.get_latest_device_data(
        GetLatestDeviceDataRequest(
            product_name="demo_product",
            device_id="device001",
            topic_name=TopicDeviceData,
        )
    )
except APIError as err:
    print(err.status_code, err.code, err.message)

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

masrobo_rcs_sdk-0.2.0.tar.gz (12.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

masrobo_rcs_sdk-0.2.0-py3-none-any.whl (7.7 kB view details)

Uploaded Python 3

File details

Details for the file masrobo_rcs_sdk-0.2.0.tar.gz.

File metadata

  • Download URL: masrobo_rcs_sdk-0.2.0.tar.gz
  • Upload date:
  • Size: 12.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.4

File hashes

Hashes for masrobo_rcs_sdk-0.2.0.tar.gz
Algorithm Hash digest
SHA256 e61b1f857c6dd70df5975e4185c7073d85fa8a466b1e5a2719ec1b7d0ac405ee
MD5 10ea3b871b85fd6df650d539e3821f47
BLAKE2b-256 6a4fb2d97436316259667d4dfaf841f5ed433a53f9f536e89ed47c833e47e37d

See more details on using hashes here.

File details

Details for the file masrobo_rcs_sdk-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for masrobo_rcs_sdk-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 364e85e392d52551bf5f330e8f4487b954dce9c6762a2bb9a4993b6dce803bd2
MD5 14f53f82a164e9ee685ab09c9b56c5e9
BLAKE2b-256 34233925883f67ec23d9f661d00c3ec14622f47224543f47ca3db851d92734cb

See more details on using hashes here.

Supported by

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