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

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: python-glinet-0.1.4.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.4.tar.gz
Algorithm Hash digest
SHA256 7acb0b99e3a85f0b3af62097f9a6d2126df9028ad2d761a158ed5496190530cf
MD5 cd9033ba227279d0b9aba7ec4d8fae8e
BLAKE2b-256 2563a401b43408d64df3288e9e5885b6649883c2fe5721baa0590f82482f13cb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for python_glinet-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 594df7e9ad4b98459c0b6a6f17f44e091278b578fb3050b69625d6ae2c34a9ac
MD5 b7435b935bcd6a261edfaa2cc493c524
BLAKE2b-256 6ec7bc4c916c4908692e955f254b5f5c2bc3177b36141e29d4c86e22dc113d94

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