TP-Link Easy Smart Switch REST API wrapper and .NET client library
- TypeScript 60.7%
- C# 37%
- Shell 2.3%
|
|
||
|---|---|---|
| docs | ||
| src | ||
| TPLink.SwitchClient | ||
| .env.example | ||
| .gitignore | ||
| .woodpecker.yaml | ||
| package-lock.json | ||
| package.json | ||
| README.md | ||
| release.sh | ||
| tsconfig.json | ||
tplink-switch-api
REST API wrapper for TP-Link Easy Smart switches (TL-SG1024DE and compatible models). Replaces the web interface for programmatic control and monitoring.
Features
- Ports — statistics, enable/disable, speed/duplex, flow control, bandwidth limits, storm control
- VLANs — 802.1Q create/delete/modify, port membership (tagged/untagged), PVID assignment
- System — info, rename, reboot, LED toggle
- Diagnostics — cable test per port
Quick start
cp .env.example .env
# edit .env with your switch IP and credentials
npm install
npm run dev
Server listens on PORT (default 3003).
Environment
| Variable | Default | Description |
|---|---|---|
PORT |
3003 |
API listen port |
SWITCH_IP |
192.168.1.5 |
Switch IP address |
SWITCH_USERNAME |
admin |
Switch admin username |
SWITCH_PASSWORD |
adminpass |
Switch admin password |
API
See ENDPOINTS.md for full endpoint reference.
GET /api/system
GET /api/ports
GET /api/ports/:id
POST /api/ports/:id/config
POST /api/ports/:id/cable-test
GET /api/vlan/8021q
POST /api/vlan/8021q
DELETE /api/vlan/8021q/:vid
GET /api/ports/pvid
POST /api/ports/:id/pvid
.NET Client
A .NET 10 client library is included under TPLink.SwitchClient/:
var options = new SwitchClientOptions {
SwitchWebAddress = "http://192.168.1.5",
Username = "admin",
Password = "admin"
};
var manager = new SwitchManager(new WebClient(options));
await manager.Login();
var ports = await manager.GetPortStatus();
CI
Woodpecker CI builds and publishes a release artifact (tplink-switch-api-dist.tar.gz) to Releases on every push to main.
