Python3 client for Gl.Inet LUCI API firmware 4.0 onwards.
Project description
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.
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
- [ ] Cli 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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file python_glinet-0.8.2.tar.gz.
File metadata
- Download URL: python_glinet-0.8.2.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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
244d5b7925a207751e1655af74ebd3a819215e9e2ab9d28850f378b8a0c22c26
|
|
| MD5 |
cc5a78673831fae57e0beff05c9e1b40
|
|
| BLAKE2b-256 |
24f2fc20fcc03ed76d9855d773fc693de88d7304d924dfab4424daa6f35d8116
|
File details
Details for the file python_glinet-0.8.2-py3-none-any.whl.
File metadata
- Download URL: python_glinet-0.8.2-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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0db58753c7ab306fa9c9770e71c8ec635f4d476320117f6e1fee16b6e84f9678
|
|
| MD5 |
eab50a62306064c85418e28d056acfff
|
|
| BLAKE2b-256 |
18bf814ca423ebb7fcbd541bca4396edcbd97ec6bf3595e61ce3c2fde56513f8
|