python-netgear-switch-library¶
Query and control Netgear switches — Fully Managed, Smart Managed Pro and Plus —
over SNMP, NSDP, the HTTP web UI and the FASTPATH CLI, behind one
model-driven Python API, the ngsw command-line tool, and an MCP server.
Warning
This library and this documentation were written by an AI. Every line of code, every test and every page here was generated by a language model, with a human directing the work and reviewing it.
Read that as a reason to check things, not to dismiss them. What it means in practice:
Device behaviour is measured, not invented. Protocol details, endpoint paths and firmware quirks come from captured traffic and live runs against the actual switches, recorded with the host and firmware version they were observed on. Where something was inferred rather than measured, the library says so and refuses to dispatch — see Concepts.
The support tables are generated from the code, not written by hand, so they state what the library will really do.
An AI is nonetheless capable of confident, fluent error. Prose can be wrong in ways tests do not catch. If a claim here matters to you, verify it against the linked source — every file reference on this site links to the file — or against your own hardware.
Nothing here has been through independent human review at scale. Treat it as you would any young project: useful, honest about its gaps, and not yet battle-tested.
Bug reports are especially welcome, and especially useful.
from netgear_switch import Backend, SyncSwitch, get_model
switch = SyncSwitch(
get_model("gsm7252ps"), host="10.1.5.22", snmp_community="public"
)
for port in switch.get_ports():
print(port.port, port.link_up, port.speed_mbps)
# The same VLANs over the web UI instead. Same types, same values.
vlans = switch.get_vlans(backend=Backend.HTTP)
from netgear_switch import AsyncSwitch, Backend, get_model
switch = AsyncSwitch(
get_model("gsm7252ps"), host="10.1.5.22", snmp_community="public"
)
for port in await switch.get_ports():
print(port.port, port.link_up, port.speed_mbps)
# The same VLANs over the web UI instead. Same types, same values.
vlans = await switch.get_vlans(backend=Backend.HTTP)
Every example on this site is shown both ways — pick one and the whole page follows.
What this library gives you¶
The same operations on every protocol a switch speaks. Every read and every write is implemented across SNMP, NSDP, the web UI and the FASTPATH CLI, so the caller picks — useful when SNMP writes are locked down, or when the web port is all a firewall allows. Reading VLANs over SNMP, HTTP and SSH returns the same values, and the tests assert it. Where a gap remains, it is listed in Support matrix, with the reason.
Plus switches, not only managed ones. The GS110EMX, GS305EP and GS105PE have no SNMP agent at all; they are driven over NSDP, an undocumented UDP protocol reverse-engineered here down to its write authentication — including the salted challenge-response on newer firmware. NSDP records what was measured and how.
A faithful fake ships with it. ngsw serve runs mock switches on real
sockets: point snmpwalk, a monitoring agent, or your own code at one. They
reproduce refusals as carefully as successes — the right SMI error status, the
same preconditions, the same ordering requirements — because half your error
handling is only reachable that way. See Testing against the fake.
Measured, and labelled as such. Device behaviour here comes from captured
traffic and live runs, recorded with the host and firmware it was seen on. Where
something is not verified, the library says so and refuses to dispatch rather
than hand back unchecked output — netgear_switch.capabilities exposes that
status, and the support tables are generated from it.
Start here¶
Installation — pip, apt, and the net-snmp system dependency.
Quickstart — a first read, against a mock, in under a minute.
Support matrix — which model can do what, over which protocol.
ngsw command line — the complete
ngswreference.