TP-Link Easy Smart Switch REST API wrapper and .NET client library
  • TypeScript 60.7%
  • C# 37%
  • Shell 2.3%
Find a file
Jordan Carter 7373c0e28c
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
docs: add screenshot and update README
2026-03-26 03:21:11 +00:00
docs docs: add UI screenshot 2026-03-26 03:20:34 +00:00
src Add SwitchAPI core class 2026-03-26 02:58:26 +00:00
TPLink.SwitchClient Add SwitchManager high-level API 2026-03-26 02:58:30 +00:00
.env.example Add .env.example 2026-03-26 02:58:10 +00:00
.gitignore Add .gitignore 2026-03-26 02:58:09 +00:00
.woodpecker.yaml ci: restructure pipeline to match netflow pattern 2026-03-26 03:17:01 +00:00
package-lock.json Add package-lock.json 2026-03-26 02:58:54 +00:00
package.json Add package.json 2026-03-26 02:58:11 +00:00
README.md docs: add screenshot and update README 2026-03-26 03:21:11 +00:00
release.sh ci: port release.sh from netflow pattern 2026-03-26 03:17:59 +00:00
tsconfig.json Add tsconfig.json 2026-03-26 02:58:12 +00:00

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.

Switch Control UI

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.