Skip to main content

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

Project description

python-glinet - A Python3 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.

The best way to navigate through the api is within an ipython shell. A wrapper is on the roadmap, but for now you must start ipython first and then load the module. Of course you can build your own application around, just bear in mind that the api function calls are generated on the fly.

My original use case was to automatically generate and write nordvpn wireguard configs to the router but then found an elegant way to autogenerate calls for the whole api and it got out of hand :).

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 connection 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
  • Publish pip package
  • Add tests
  • 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.6.tar.gz (21.4 kB view details)

Uploaded Source

Built Distribution

python_glinet-0.1.6-py3-none-any.whl (21.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: python-glinet-0.1.6.tar.gz
  • Upload date:
  • Size: 21.4 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.6.tar.gz
Algorithm Hash digest
SHA256 3f86c8784da39406c26a516eb56a8d6b07809b66e9fb5dbc943c430f69b416ca
MD5 6f5c6afd0afbdb46317342a06024ce65
BLAKE2b-256 a5960df116d0a85e78041be83a59769fbbbf0293cacdcfec670b3a3c31ab16e4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for python_glinet-0.1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 9dbd2e792d4bec6d5afb3957bef9a947107cf2a80963c40e77906138fe797ef2
MD5 bfbfc2773fe54bbbb428fb56d62a36ef
BLAKE2b-256 9a7ffd8480e0c7e358b001e609e9fab80e9999a2f1b9d58423df6003806347b6

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