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:

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

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: python-glinet-0.1.3.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.3.tar.gz
Algorithm Hash digest
SHA256 f714768ece4656c09e8e2bd1c71e47656ba3f08a97aad6d8ccb3dd23c24c5742
MD5 7a277b33dfce490416e48a496ff387b1
BLAKE2b-256 653ed66bc7cf4c85cf18f881745c21d7d976ab8094195a60e52e6a3f3eda1fc2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for python_glinet-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 a779116fb95cc05c1733431d23a743670107903284413bca017c6461fffc2056
MD5 11392667744a63ca51ee2f61dc93d5c9
BLAKE2b-256 0172fd1fcabca095a9e60fec75ca0cc95f010fd7ca1a2d41d6cd07744008d04a

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