Skip to main content

This package gives client access to the Gl-Inet json-rpc for firmware >=4.0

Project description

pyglinet - A Python 3 client for GL-Inet Router

This package aims to provide full access to the GL-Inet Luci API for firmware versions >= 4.0 via json-rpc.

There is no official English documentation of the API yet. The lib parses the Chinese documentation from here and dynamically creates the functions.

I initially created the client to automatically generate and write nordvpn wireguard configs to the router but then found an elegant way to autogenerate calls for the whole api.

The best way to navigate through the api is within an ipython shell. I may add in future a wrapper but for now you must start the shell first and then load the module.

Features

  • Complete API support
  • Dynamic method creation inclusive docstring from online documentation
  • Api responses are represented recursively as objects, such that you can access all properties via '.'
  • Cache for api description and hashed login
  • Configure background thread to keep connection alive

Installation:

PiP

pip install python-glinet

Clone Repo

#clone repository
git clone https://github.com/tomtana/python-glinet.git
cd python-glinet

Install package directly. The -e parameter lets you edit the files. If this is not needed to can also install without the -e parameter.

pip install -e .

Alternatively install it in an Python virtual environment (see here for more infos)

python3 -m venv venv
source venv/bin/activate
pip install -e .

Examples:

Login

Login is as easy as that. If you modified your ip-address or other parameter, you need to pass them as parameter (see the documentation of the GlInet class for more details).

Per default the following steps are executed:

  • if no password is passed
    • try to load from persistance (password stored as hash)
    • if no success ask via prompt
  • try to load api reference from persistence, otherwise load it from the web
  • persist settings
  • start background thread to keep connectio alive
from pyglinet import GlInet
glinet = GlInet()
glinet.login()

API usage

First you need to generate an api object.

client = glinet.get_api_client()

Now you can intuitively navigate the api using code completion and docstring.

ToDos:

  • Add dynamically docstring for API calls
  • Create pip compliant package
  • Add tests
  • Publish pip package
  • Improve documentation
  • Add wrapper for execution via terminal

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.1.5.tar.gz (21.3 kB view details)

Uploaded Source

Built Distribution

python_glinet-0.1.5-py3-none-any.whl (21.3 kB view details)

Uploaded Python 3

File details

Details for the file python-glinet-0.1.5.tar.gz.

File metadata

  • Download URL: python-glinet-0.1.5.tar.gz
  • Upload date:
  • Size: 21.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.5

File hashes

Hashes for python-glinet-0.1.5.tar.gz
Algorithm Hash digest
SHA256 1b0be19a246f7e2d4989c9485cfbb2a8857c7809727a421b5ad971132fb9eaab
MD5 ed1bcb5d0310ebbeae5f917df11dbc9b
BLAKE2b-256 4f8e5fa8965b07902eed9812af38277092b4ca48e3acd5be9c815838393dc5c5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for python_glinet-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 30f0cb36574d9d771befce4c618bd9d4f99071b5af28bc5f6e07652e063c43ff
MD5 7c405c89386522f61579f051889d8f3c
BLAKE2b-256 70709627736f0d85d505a98068dbeb6f5124f9984c8428ce653b1e2e6eb2f1a0

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page