Skip to main content

OpenWRT ubus API

A Python library for asynchronous access to the ubus interface on OpenWRT devices.

Requirements

  • Python 3.10+
  • aiohttp

Quick Start

from aio_openwrt import Ubus

async with Ubus("192.168.1.1", "username", "password") as client:
    await client.login()
    dev = await client.network.device.status(name="lan1")
    print(dev)

Usage

Connection livetime

Use async with to automatically manage the session:

async with Ubus(host, user, password) as client:
    await client.login()
    dev = await client.network.device.status(name="lan1")

Without a with block, a session is created automatically on the first request. In that case, call close() manually when done:

client = Ubus(host, user, password)
try:
    await client.login()
    dev = await client.network.device.status(name="lan1")
finally:
    await client.close()

Making Calls

There are two ways to interact with the device:

Typed wrappers — available for common paths and methods:

await ubus.session.login(username="...", password="...")
await ubus.network.device.status(name="lan1")
await ubus.system.board()

Direct call() — for any path/method not covered by a typed wrapper:

await ubus.call("session", "login", {"username": "...", "password": "..."})
await ubus.call("network.device", "status", {"name": "lan1"})
await ubus.call("system", "board")

Both are equivalent. The typed wrappers are a convenience layer over call().

Subscript Access For dynamically named entries such as network interfaces, use subscript notation:

await ubus.network.interface["wan"].status()

Listing objects

To list the objects directly use list():

await ubus.list("hostapd.*")

Typed wrappers with subscript access can be iterated over using list_children():

await ubus.hostapd.list_children()

Permissions

Depending on the device configuration, most features require authentication first. The authenticated user must be configured in /etc/config/rpcd with a corresponding ACL file in /usr/share/rpcd/acl.d/ granting the necessary ubus permissions. See the OpenWRT wiki for details.

Development

Install dependencies:

pip install -e ".[dev]"
pre-commit install

This will check and format using ruff the code before committing.

Metadata

Release files for aio-openwrt 0.3.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 aio-openwrt 0.3.0
File Size Uploaded Provenance Actions
aio_openwrt-0.3.0.tar.gz 10.5 kB With provenance Details for aio_openwrt-0.3.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for aio-openwrt 0.3.0
File Interpreter ABI Platform Actions
aio_openwrt-0.3.0-py3-none-any.whl Python 3 none any Details for aio_openwrt-0.3.0-py3-none-any.whl

Total release size: 19.6 kB

Release files / aio_openwrt-0.3.0.tar.gz

Download URL aio_openwrt-0.3.0.tar.gz
Size 10.5 kB
Tags Source
SHA-256 checksum
How to use checksums
b668c54407ae05879ac053f994983ee93a5d44f4caceb67419b2cc3ea01cbba8
BLAKE2b-256 checksum
How to use checksums
76c83dd5d59bbf6b696c739be020e33a012f2838d30eb8f14401fc03501d6ac6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Apr 3, 2026.

Transparency log

Release files / aio_openwrt-0.3.0-py3-none-any.whl

Download URL aio_openwrt-0.3.0-py3-none-any.whl
Size 9.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
208fc1a210e1d5ceaf9196648dbe315b326f8eaf09a8530948bede17a461adfc
BLAKE2b-256 checksum
How to use checksums
4a0e572828de5a0ab68047682511a2bf1ef4a247ca243c930de85cedd3edca28
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Apr 3, 2026.

Transparency log

Security for aio-openwrt 0.3.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

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for aio_openwrt-0.3.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Apr 3, 2026.

Transparency log

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