Skip to main content

A Python 3 async API wrapper for GL.iNet routers (firmware 4.x JSON-RPC API)

Project description

glinet4

glinet4

PyPI License: GPL-3.0

Quickstart

import asyncio

from glinet4 import GLinet


async def main() -> None:
    async with GLinet("http://192.168.8.1/rpc") as router:
        await router.login("root", "your-router-password")
        info = await router.router_info()
        print(info["model"], info["firmware_version"])


asyncio.run(main())

Swap in your router's host, username and password. login() must succeed before any other call — see API coverage below for the full method list, and CONTRIBUTING.md for how the test suite talks to a live router.

An async Python 3 API wrapper for GL.iNet routers running version 4.x firmware.

GL.iNet routers are built on OpenWRT and expose a local JSON-RPC API. glinet4 wraps that API for easy integration into other services such as Home Assistant.

glinet4 began as a fork of HarvsG/gli4py (GPL-3.0) and has since grown a much larger API surface. See NOTICE for attribution.

Installation

pip install glinet4

Dev setup

  1. Clone the repo
  2. Ensure you have Python 3.11 or greater (python3 -V) and install uv.
  3. uv sync — creates the in-project .venv and installs the runtime + dev dependencies.
  4. uvx prek install — sets up the git pre-commit hooks (ruff, mypy, file hygiene). Run them on demand with uvx prek run --all-files.
  5. The tests run against a live router, so copy .env.example to .env and set at least GLINET_PASSWORD (and GLINET_HOST if not 192.168.8.1). Without it the live suite is skipped.
  6. uv run pytest -s to see responses.
  7. Build with uv build. Releases publish to PyPI automatically on a GitHub Release (trusted publishing).

See CONTRIBUTING.md for the full contributor flow: running the live suite safely, the pre-commit/CI gates, and how to submit a device capture.

API coverage

Session: login, router_reachable. All other methods require login first.

Area Methods
System router_info, router_status, router_load, router_unixtime, router_disk_info, router_usb_info, router_timezone_config, router_mac, router_reboot
Network / WAN ping, wan_upstream_router_detected, wan_cable_state, wan_status, wan_info, ethernet_ports_status, network_mode, network_interfaces_status
Network acceleration network_acceleration, network_acceleration_set
Flow statistics flow_stats_rule, flow_stats_set_enabled, flow_stats_top_apps, flow_stats_clear
Clients clients_list, static_clients_list, connected_clients, clients_status, clients_speed, wan_speed, client_set_blocked, blocked_client_macs
WiFi wifi_ifaces, wifi_iface_set_enabled, wifi_status, wifi_mlo_config
Services adguard_config, tor_config, zerotier_config
Firmware firmware_check_online, upgrade_config
Firewall firewall_port_forward_list, firewall_dmz, firewall_wan_access, firewall_rule_list
LED led_config, led_set_enabled
WireGuard wireguard_client_list, wireguard_client_state, wireguard_client_start, wireguard_client_stop, wireguard_server_status, wireguard_server_config, wireguard_server_setting, wireguard_server_peers, wireguard_server_routes, wireguard_client_groups, wireguard_client_configs
OpenVPN openvpn_server_status, openvpn_server_config, openvpn_server_setting, openvpn_server_users, openvpn_server_routes, openvpn_client_groups, openvpn_client_configs
VPN tunnel state vpn_client_status, vpn_client_tunnels
Tailscale tailscale_configured, tailscale_connection_state, tailscale_start, tailscale_stop, tailscale_auth_url, tailscale_exit_node_list, tailscale_set_exit_node

Responses are typed with TypedDicts (see glinet4/_types.py); the package ships py.typed. The catalogue of routes still to wrap comes from the sanitised device captures submitted to glinet4-registry — run uvx glinet4-profiler against your own router to contribute one.

Todo list:

  • Decide on useful endpoints to expose
  • Expose said endpoints (ongoing — see the table above and glinet4/glinet4 issues)
  • Package correctly
  • Test that dev enviroment is re-producable
  • Publish on pip
  • Static typing

Versioning & stability

glinet4 is pre-1.0: breaking changes can land in a minor version bump, not just a major one. CHANGELOG.md (generated by release-please from conventional commits) is the authoritative record of what changed in each release — check it before upgrading.


Part of the glinet4 project — glinet4 (Python library) · glinet4-ha (Home Assistant) · glinet4-profiler · glinet4-registry

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

glinet4-0.2.2.tar.gz (42.5 kB view details)

Uploaded Source

Built Distribution

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

glinet4-0.2.2-py3-none-any.whl (47.5 kB view details)

Uploaded Python 3

File details

Details for the file glinet4-0.2.2.tar.gz.

File metadata

  • Download URL: glinet4-0.2.2.tar.gz
  • Upload date:
  • Size: 42.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for glinet4-0.2.2.tar.gz
Algorithm Hash digest
SHA256 6b7f94ea7c629296cd3f39d0d53f7d473fc936078d1727b912daa5777e02915e
MD5 09ced3f494cfb44ca3d722618946ad16
BLAKE2b-256 e140eccea800b0998f27b607ab93a283021bb4867fbea7d77a02dfaf209af889

See more details on using hashes here.

Provenance

The following attestation bundles were made for glinet4-0.2.2.tar.gz:

Publisher: publish.yml on glinet4/glinet4

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

File details

Details for the file glinet4-0.2.2-py3-none-any.whl.

File metadata

  • Download URL: glinet4-0.2.2-py3-none-any.whl
  • Upload date:
  • Size: 47.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for glinet4-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 e74a5bc1af38d96b6f97b8737892d5605f87f580ea2b0c43d4c3cbe655f92a3d
MD5 f3753dd58c3a9491ed685de2ec3c1393
BLAKE2b-256 e24b632953bbc835cfd516537aad35c559b77793d39852b1b9b049a9867a86de

See more details on using hashes here.

Provenance

The following attestation bundles were made for glinet4-0.2.2-py3-none-any.whl:

Publisher: publish.yml on glinet4/glinet4

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