Skip to main content

tapolink-proto

An async Python library for TP-Link Tapo (and current Kasa) devices, written from scratch under Apache-2.0 with no GPL code. Release 0.1 covers two things.

  • Cloud inventory (tapolink_proto.cloud): sign in to the TP-Link cloud (MFA supported), refresh tokens, list the account's devices, and read each device's current LAN IP from the IoT API. TLS is pinned to TP-Link's own root certificates. The cloud is used for inventory only; this library never controls a device through it.
  • TDP identity probe (tapolink_proto.discovery): a unicast probe on UDP 20002 that returns a device's ID, MAC, model and login scheme. Use it to check that the device at an IP is the one the cloud listed before you send it credentials. Each probe carries a random serial, and only replies that echo it are accepted.

Local device control (AES / KLAP / TPAP) is not in this release.

The Home Assistant helper tapo_onboard uses this library.

import aiohttp
from tapolink_proto.cloud import CloudClient, build_cloud_ssl_context

async with aiohttp.ClientSession() as http:
    client = CloudClient(
        http,
        ssl_context=build_cloud_ssl_context(),  # blocking; run in an executor
        terminal_uuid=my_stable_uuid4,  # generate once, keep forever
    )
    session = await client.login(email, password)
    for device in await client.list_devices(session):
        details = await client.device_details(session, device)
        print(device.alias, device.model, details.ip)

Rate limits. TP-Link locks accounts that call the cloud too often (error -20004). Keep it to one login, a device list about every 30 minutes, and a details lookup only when you need a device's address.

Not affiliated with or endorsed by TP-Link.

Metadata

Release files for tapolink-proto 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for tapolink-proto 0.1.0
File Size Uploaded Provenance Actions
tapolink_proto-0.1.0.tar.gz 22.9 kB With provenance Details for tapolink_proto-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for tapolink-proto 0.1.0
File Interpreter ABI Platform Actions
tapolink_proto-0.1.0-py3-none-any.whl Python 3 none any Details for tapolink_proto-0.1.0-py3-none-any.whl

Total release size: 45.1 kB

Security for tapolink-proto 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page