API to some budget TP-Link routers
Project description
tplink-wr-api
Python API to some budget TP-Link routers.
Supported devices
This library designed for budget models with firmware without API. Library interacts with router management interface like user (scrape HTML UI) so it may not work with others versions of firmware.
Tested with TL-WR840N v2 with firmware version 3.16.9.
Features
Currently only read operations are available:
- general status info
- WLAN clients
- DHCP leases
Usage
>>> from tplink_wr import RouterSession, fetchers
>>>
>>> rt = RouterSession("192.168.0.1", "admin", "admin")
>>>
>>> general = fetchers.status.GeneralStatus.fetch(rt)
>>> print(general.lan)
LANStatus(mac='12-34-56-78-90-AB', ip='192.168.0.1', mask='255.255.255.0')
>>> stats = fetchers.wlan.WLANStats.fetch(rt)
>>> leases = fetchers.dhcp.DHCPLeases.fetch(rt)
>>>
>>> import pprint
>>> pp = pprint.PrettyPrinter(indent=2)
>>> pp.pprint(general.dict())
{ 'device_type': <RouterType.WAN: 1>,
'firmware': '3.16.9 Build 150929 Rel.37860n ',
'hardware': 'WR840N v2 00000000',
'lan': { 'ip': '192.168.0.1',
'mac': '12-34-56-78-90-AB',
'mask': '255.255.255.0'},
'mode_3g': False,
'rx_bytes': 3330853277,
'rx_packets': 8909427,
'tx_bytes': 550131568,
'tx_packets': 2593047,
'uptime': 99788,
'wan': [ { 'dns': '1.2.3.0 , 1.2.3.1',
'gateway': '1.2.10.1',
'ip': '1.2.10.15',
'link_status': <WANLinkStatus.LINK_UP: 4>,
'mac': '12-34-56-78-90-AC',
'mask': '255.255.224.0',
'type': <WANType.DYNAMIC: 1>}],
'wireless': True,
'wlan': { 'channel_auto': 6,
'channel_manual': None,
'channel_width': <WLANChannelWidth.AUTO: 2>,
'enabled': True,
'ip': '192.168.0.1',
'mac': '12-34-56-78-90-AB',
'name': 'TP-LINK_90AB',
'type': <WLANType.BGN_MIXED: 6>,
'wds_status': <WDSStatus.DISABLE: 6>}}
>>> pp.pprint(stats.dict())
{ 'clients': [ {'mac': '81-69-01-93-77-49', 'rx': 341, 'tx': 217},
{'mac': 'C4-49-F0-84-00-52', 'rx': 179, 'tx': 90}],
'mac_filter_enabled': False,
'mac_filter_whitelist': False,
'ssid': ['TP-LINK_90AB']}
>>> pp.pprint(leases.dict())
{ 'leases': [ { 'expire': 6701,
'ip': '192.168.0.110',
'mac': '65-CD-44-29-F2-0A',
'name': 'DESKTOP-ABCDEFG'},
{ 'expire': 6973,
'ip': '192.168.0.100',
'mac': '81-69-01-93-77-49',
'name': 'OnePlus-9R'},
{ 'expire': 7186,
'ip': '192.168.0.102',
'mac': 'C4-49-F0-84-00-52',
'name': 'arch'}]}
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 tplink-wr-api-0.2.1.tar.gz.
File metadata
- Download URL: tplink-wr-api-0.2.1.tar.gz
- Upload date:
- Size: 9.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
32042cb6976acfb16b24a12d3129bb3ca591d75f9a50d456e7a8316d27fd9b34
|
|
| MD5 |
5c7bf2879123d4f4a6e8dc484f1a93fa
|
|
| BLAKE2b-256 |
07e957da79953e4cace6749edeb7f2eb39a8ee0f5c591cf5f7681c3bfe7acb7b
|
File details
Details for the file tplink_wr_api-0.2.1-py3-none-any.whl.
File metadata
- Download URL: tplink_wr_api-0.2.1-py3-none-any.whl
- Upload date:
- Size: 10.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7a45cc8a664f470410a79b1857b3fcabd0720c69ff7dcf586a84e663191caa2e
|
|
| MD5 |
7d50d823e303521967fe692e50445a8c
|
|
| BLAKE2b-256 |
b31332311b2be70c28a94fac68ed77eceab50c58cdd215b8037359c7fa68fb79
|