Skip to main content

Execute API calls to Omada Controller from python code

Project description

omada-client

PyPI Version PyPI Version Tests

Python client for Tp-Link Omada Controller (Omada Software Controller). Allows executing API calls to the Omada Controller from Python code.


Installation

pip install omada-client

Quick Start

Using direct credentials

from omada_client import OmadaClient

omada = OmadaClient(
    "OMADA_DOMAIN",    # URL of Omada WebUI
    "OMADA_USER",      # Username
    "OMADA_PASSWORD",  # Password
    "SITE_ID"          # Site identify (Optional. Default: First site in list)
)

Using environment variables

from dotenv import load_dotenv
import os
from omada_client import OmadaClient

load_dotenv()

omada = OmadaClient(
    os.getenv("OMADA_DOMAIN"),
    os.getenv("OMADA_USER"),
    os.getenv("OMADA_PASSWORD"),
    os.getenv("SITE_ID")
)

print(omada.get_devices())

Methods Reference

Category Method Parameters Description
WAN Ports get_all_wan_ports() None List all WAN ports
get_wan_ports_by_name(name) name: str Get WAN port by name
get_wan_ports_by_desc(desc) desc: str Get WAN port by description
Wireless get_all_wlan() None List all Wi-Fi networks
get_wlan_by_ssid(ssid) ssid: str Get Wi-Fi network by SSID
Static Routes create_static_route(route_name, destinations, interface_id, next_hop_ip, enable=False, metricId=0) route_name: str, destinations: list[str], interface_id: str, next_hop_ip: str Create a single static route
create_static_route_to_inteface_with_big_data(data_static_routes, interface_id, next_hop_ip, enable=False, metricId=0) data_static_routes: list, interface_id: str, next_hop_ip: str Create static routes from large data
Devices & Clients get_devices() None List all devices
get_clients() None List all clients
get_client_by_mac(mac) mac: str Get client by MAC
get_client_by_ip(ip_address) ip_address: str Get client by IP
create_group_ip_v4(group_name, ip_v4_list) group_name: str, ip_v4_list: list[GroupMemberIpv4Model] Create new group IPv4 addresses
delete_ipv4_from_group_by_name(group_name, ip_v4) group_name: str, ip_v4: GroupMemberIpv4Model Remove IPv4 address from group by name
Groups get_all_groups() List all groups
get_group_by_id(id) id: str Get group port by ID
get_group_by_name(name) name: str Get group port by Name
IP Assignment set_client_fixed_address_by_mac(mac, ip_address=None) mac: str, ip_address: str Assign fixed IP by MAC
set_client_fixed_address_by_ip(ip_address) ip_address: str Assign fixed IP by IP
set_client_dymanic_address_by_mac(mac) mac: str Assign dynamic IP by MAC

Advanced Example

Create static routes from large data sets

from dotenv import load_dotenv
import os
from omada_client import OmadaClient

load_dotenv()

omada = OmadaClient(
    os.getenv("OMADA_DOMAIN"),
    os.getenv("OMADA_USER"),
    os.getenv("OMADA_PASSWORD")
)

data = [
    {"name": "group_1", "ips": "99.99.99.99/24, 88.88.88.88/24"},
    {"name": "group_2", "ips": "99.99.99.99/24, 88.88.88.88/24"}
]

wan = omada.get_wan_ports_by_desc("openwrt")

omada.create_static_route_to_inteface_with_big_data(
    data_static_routes=data,
    interface_id=wan.port_uuid,
    next_hop_ip=wan.wan_port_ipv4_setting.get("ipv4Static").get("gateway"),
    enable=False
)

Notes

  • Replace all IPs, MAC addresses, and credentials with real values.
  • Environment variables help keep sensitive credentials out of code.
  • Use badges above to quickly check test status and PyPI version.

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

omada_client-1.2.19.tar.gz (12.0 kB view details)

Uploaded Source

Built Distribution

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

omada_client-1.2.19-py3-none-any.whl (11.7 kB view details)

Uploaded Python 3

File details

Details for the file omada_client-1.2.19.tar.gz.

File metadata

  • Download URL: omada_client-1.2.19.tar.gz
  • Upload date:
  • Size: 12.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for omada_client-1.2.19.tar.gz
Algorithm Hash digest
SHA256 55c8c2e5e0154d8902d2deb7f25382a4374d548b54e561763c3a48e57c9d7c2c
MD5 22b49a7a29a676932c2345a4c16dfe1d
BLAKE2b-256 051c128ff426241e103c83bedfe8a06f5d14a6bc8748fd57c5b4bbce9bd64be4

See more details on using hashes here.

Provenance

The following attestation bundles were made for omada_client-1.2.19.tar.gz:

Publisher: publish-pypi.yml on ErilovNikita/omada-client

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

File details

Details for the file omada_client-1.2.19-py3-none-any.whl.

File metadata

  • Download URL: omada_client-1.2.19-py3-none-any.whl
  • Upload date:
  • Size: 11.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for omada_client-1.2.19-py3-none-any.whl
Algorithm Hash digest
SHA256 24203016150bf13af12000c0ff85c17f90bd25c666b20aff2a2249e065977c82
MD5 509d5df76ed62b1490c947aad0d0bcd1
BLAKE2b-256 792aeea94b9fb2c8b4341a5f2dcf5dd60348ce149b43d9aecf8c4fcc5ee121de

See more details on using hashes here.

Provenance

The following attestation bundles were made for omada_client-1.2.19-py3-none-any.whl:

Publisher: publish-pypi.yml on ErilovNikita/omada-client

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