Level 3 is done: your scripts can call REST APIs.
You now move one level up:
You are at level 4: you learn the APIs of Cisco devices and controllers.
The first step is to know what a device-level API is.Answer the question below
Which level are you at now?
A device-level API is a programmatic interface built directly into a switch or router.
Your script connects straight to each device's management IP and configures it one by one, with no central controller in between.Answer the question below
Does a device-level API need a central controller: yes or no?
CLI Text Output
The CLI formats output for humans, not scripts.
When you run a show command, your switch prints a text table:SW1# show vlan brief VLAN Name Status Ports ---- ---------------- --------- --------------- 10 USERS active Gi0/1, Gi0/2To extract the VLAN name, your script has to split lines and count spaces.
If an OS update adds a column or shifts a space, your script breaks.Structured API Data
A device-level API skips screen formatting and returns structured data.
Every value is paired with an explicit key:{ "vlan": 10, "name": "USERS", "status": "active", "ports": ["Gi0/1", "Gi0/2"] }Your script reads each value directly by its key.
Answer the question below
Was the CLI made for humans or for scripts?
Cisco IOS XE supports two device-level APIs to read and modify device configuration.
NETCONF
NETCONF runs over SSH on TCP port 830 and encodes data in XML.
Using port 830 instead of port 22 tells your switch immediately that the session carries API messages, not CLI commands.RESTCONF
RESTCONF runs over HTTPS on TCP port 443.
It uses standard HTTP methods (GET to read data, POST or PATCH to modify it) and encodes data in JSON or XML.
Figure 1 - The Two APIs of IOS XE
Both APIs read and modify the same device data, organized by YANG models.
YANG defines the structure of switch features such as interfaces, VLANs, and routes.Enabling NETCONF and RESTCONF
Both APIs are disabled by default on IOS XE.
Enable them in global configuration mode:SW1# conf t Enter configuration commands, one per line. End with CNTL/Z. SW1(config)# netconf-yang SW1(config)# restconfAnswer the question below
Which port does NETCONF use?
Cisco Nexus switches run NX-OS and expose a native HTTPS API called NX-API.
NX-API CLI
NX-API CLI wraps standard CLI commands inside an HTTPS request.
Your script sends a command likeshow vlan brief, and the switch returns the output formatted in JSON or XML.NX-API REST
NX-API REST treats the switch configuration as a tree of objects.
Instead of sending CLI commands, your script reads or modifies switch settings directly through HTTPS URLs using JSON or XML.
Figure 2 - The Two Forms of NX-API
Enabling NX-API
Enable NX-API in global configuration mode:
SW2# conf t Enter configuration commands, one per line. End with CNTL/Z. SW2(config)# feature nxapiNX-OS also supports NETCONF and RESTCONF.
In the next lesson, you will see how YANG models structure device data.Answer the question below
Which operating system has NX-API: IOS XE or NX-OS?