Skip to main content

Python3 client for Gl.Inet LUCI API firmware 4.0 onwards.

Project description

GitHub Workflow Status (event) GitHub Workflow Status PyPI - Python Version PyPI Code Cov

python-glinet: Python 3 Client for GL.iNet Routers

Introduction

python-glinet is a robust Python 3 library for interacting with GL.iNet router's LuCI API on firmware 4.x and later. It enables developers to programmatically manage and configure GL.iNet routers with features like dynamic API method generation, object-oriented response parsing, and automated session maintenance. Ideal for automation scripts and integrations, it supports interactive exploration via IPython.

python-glinet demonstration

Features

  • Comprehensive API Coverage: Full access to LuCI API endpoints for firmware 4.x+.
  • Dynamic Methods: Auto-generates methods with docstrings from API documentation.
  • Intuitive Responses: Converts JSON responses to objects for dot-notation access.
  • Session Handling: Background thread for connection persistence; cached credentials.
  • Interactive Support: Optimized for IPython with code completion and docstrings.

[!NOTE]

  • Supports firmware 4.x+ only, following GL.iNet's JSON-RPC transition.
  • Uses archived API snapshot from Internet Archive .

Installation

Via pip (recommended in a virtual environment):

pip install python-glinet

From source for development:

git clone https://github.com/tomtana/python-glinet.git
cd python-glinet
python3 -m venv venv
source venv/bin/activate
pip install -e .

See Python's venv guide for details on virtual environments.

Quick Start

The GlInet class manages authentication and API interactions. Customize defaults (e.g., IP, username) via constructor parameters. Refer to class docs.

from pyglinet import GlInet
glinet = GlInet().login()  # Instantiates and logs in

[!WARNING] Do not pass passwords in code; use persistence or prompts for security.

[!NOTE]

  • Loads API description from cache or online.
  • login() handles credentials and starts session keeper.

API Usage

Dynamic Client

In IPython, after login:

api_client = glinet.get_api_client()
  • Structure: api_client.<group>.<method>
  • Naming: Hyphens replaced with underscores (e.g., wg_client).
  • Navigation: Use tab completion and ? for docstrings.

Examples

List groups:

api_client

Explore methods:

api_client.wg_client

View parameters:

api_client.wg_client.set_config

Docstring:

api_client.wg_client.set_config?

Call method:

api_client.wg_client.get_all_config_list()

Responses are objects for easy access.

Direct Requests

glinet.request("call", ["adguardhome", "get_config"])

Equivalent to api_client.adguardhome.get_config(), but returns full response.

Roadmap

  • [x] Dynamic docstrings
  • [x] PyPI package
  • [x] Tests and coverage
  • [x] Windows compatibility
  • [ ] Terminal wrapper

Contributing

Welcome contributions! Fork, branch, and PR on GitHub. Test changes and follow roadmap.

For issues, use GitHub Issues.

License

MIT License. See LICENSE.

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

python_glinet-0.8.1.tar.gz (130.1 kB view details)

Uploaded Source

Built Distribution

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

python_glinet-0.8.1-py3-none-any.whl (122.4 kB view details)

Uploaded Python 3

File details

Details for the file python_glinet-0.8.1.tar.gz.

File metadata

  • Download URL: python_glinet-0.8.1.tar.gz
  • Upload date:
  • Size: 130.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.24

File hashes

Hashes for python_glinet-0.8.1.tar.gz
Algorithm Hash digest
SHA256 8b41c0c8a5a0f3bd7f12f7d9cfb416eb5a46fd249262a952ef0419dac5c6c4f6
MD5 0d25d989abb804313f1bd3643e5b9637
BLAKE2b-256 c76d990c40b6bb166925fbae6b995b41c752b76ffcd6706201c1000330a4a425

See more details on using hashes here.

File details

Details for the file python_glinet-0.8.1-py3-none-any.whl.

File metadata

  • Download URL: python_glinet-0.8.1-py3-none-any.whl
  • Upload date:
  • Size: 122.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.24

File hashes

Hashes for python_glinet-0.8.1-py3-none-any.whl
Algorithm Hash digest
SHA256 23dcfa03e720b4234f3304b5107a96051113372ed2ffbcb85460024d5f9e3854
MD5 92b8089376b1c49aca47ca409fc284fa
BLAKE2b-256 04b908a0b3f8be49921e64bb2a4200d120aefd4cf52a51bd84129fc362e9e156

See more details on using hashes here.

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