Skip to main content

Unofficial Python client for the Landbook (Netprisma/Landecia) smart home cloud API — REST auth/device discovery and MQTT pub/sub.

Project description

landbook-api

Unofficial Python client for the Landbook smart home cloud API (Netprisma/Landecia), reverse-engineered from the Landbook iOS app. Covers:

  • REST: email/password login, token refresh, device discovery, TSL (Thing Specification Language) model fetch, device attribute reads.
  • MQTT: a persistent WebSocket/TLS pub-sub connection for real-time device control and state (LandbookMQTTClient).

This library powers the landbook-ha Home Assistant integration, but has no dependency on Home Assistant and can be used standalone.

Installation

pip install landbook-api

Usage

from landbook_api import login, get_device_list, get_tsl, LandbookMQTTClient

bearer_token, uid, refresh_token = login("you@example.com", "your-password", region="us")

devices = get_device_list(bearer_token, region="us")
pk = devices[0]["productKey"]
dk = devices[0]["deviceKey"]

properties = get_tsl(bearer_token, pk, region="us")

client = LandbookMQTTClient(uid, bearer_token)
client.connect()

def on_message(topic_suffix: str, payload: dict) -> None:
    print(topic_suffix, payload)

device_id = f"qd{pk}{dk}"
client.subscribe_device(device_id, on_message)
client.send_read(device_id, pk, dk, [p["code"] for p in properties])

Async equivalents (async_login, async_get_device_list, async_get_tsl, async_refresh_token, async_get_device_attributes) are also exported — each wraps the sync call in a thread executor.

Supported Regions

Region API
United States iot-api.quectelus.com
Europe iot-api.quecteleu.com
China iot-gateway.quectel.com

Pass region="us", "eu", or "cn" to any call (defaults to "us"). EU and CN are untested — reports welcome via issues.

Session Tokens

login() returns a (bearer_token, uid, refresh_token) tuple. The access token (bearer_token) is valid for 2 hours; the refresh token is valid for 30 days and must be used to obtain a new pair via refresh_token() before the access token expires. Both values should be persisted by the caller — this library does not manage token storage.

Development

pip install -e ".[test]"
pytest

Disclaimer

This is an unofficial, reverse-engineered client with no affiliation to Landbook, Netprisma, or Landecia. It may break if the upstream API changes.

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

landbook_api-0.1.0.tar.gz (9.1 kB view details)

Uploaded Source

Built Distribution

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

landbook_api-0.1.0-py3-none-any.whl (9.4 kB view details)

Uploaded Python 3

File details

Details for the file landbook_api-0.1.0.tar.gz.

File metadata

  • Download URL: landbook_api-0.1.0.tar.gz
  • Upload date:
  • Size: 9.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for landbook_api-0.1.0.tar.gz
Algorithm Hash digest
SHA256 b8bfd07869e730d7675f67e2f0d3446513f084ca3a460e32bfccf4fa8fafee24
MD5 71332a76c5329c6a1c6d3e8ea27cbb4a
BLAKE2b-256 2f890bdd1d7fd945cd0802a37401e7af65b5f601329b9bb2cb6fb6bfb1052907

See more details on using hashes here.

Provenance

The following attestation bundles were made for landbook_api-0.1.0.tar.gz:

Publisher: release.yml on zackwag/landbook-api

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file landbook_api-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: landbook_api-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 9.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for landbook_api-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c9e027a1240aff6c326842812ab88908aa3dae96310f3b69f3c1777fb90208c9
MD5 677e0aedb64699e46ce8e2d42f75d06e
BLAKE2b-256 c795ac1db1bc23baf15e58bca4761e0372f1205318efec518b255498c1cbd1cd

See more details on using hashes here.

Provenance

The following attestation bundles were made for landbook_api-0.1.0-py3-none-any.whl:

Publisher: release.yml on zackwag/landbook-api

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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