Skip to main content
Your first session is free. Claim mine
PacketMentor logo
Open menu
Home
Training
CCNA Library (74)
Browse all CCNA topics →
Network (13)
Device Operations (5)
Network Access (12)
Wireless (6)
IP Connectivity (10)
IP Services (11)
Security (10)
Automation (7)
CCNP Library (15)
LabsPricing
Contact 📞 +1 (860) 556-3010 Book a Call
← All topics
Automation & Programmability Foundational

REST APIs for Network Engineers

Modern Cisco devices expose REST APIs so you can configure them with HTTP requests and JSON instead of SSH and screen-scraping. Covers verbs (GET/POST/PUT/DELETE), authentication, data formats, and where REST fits in network automation.

TL;DR
  • REST APIs let you read and change device state with HTTP requests. Modern Cisco platforms (IOS-XE, NX-OS, Meraki, DNA Center) expose them.
  • Four core verbs: GET (read), POST (create), PUT (replace), DELETE (remove). Status codes (2xx = ok, 4xx = your fault, 5xx = server fault) say what happened.
  • Data is JSON or XML. JSON wins for almost every use case.

Mental model

Old way: SSH into a router, type show ip interface brief, parse the text output with regex, hope the format doesn’t change between IOS versions.

New way: send GET /restconf/data/ietf-interfaces:interfaces to the router’s HTTPS endpoint, get back structured JSON. Parse with one line of Python. No regex. No surprises when IOS updates.

That’s the elevator pitch for REST APIs. They turn network gear into something a normal application can talk to.

The four verbs

VerbWhat it doesExample
GETRead state — no changesGET /interfaces → list all interfaces
POSTCreate something newPOST /vlans with body {"id": 10, "name": "USERS"}
PUTReplace something entirelyPUT /interfaces/Gi0/1 with full new config
DELETERemove somethingDELETE /vlans/10

There’s also PATCH (partial update) but it’s less common. For CCNA-level, know the big four.

Status codes you’ll actually see

CodeMeaningCause
200 OKSuccess, response body has dataGET worked
201 CreatedSuccess, new resource madePOST worked
204 No ContentSuccess, nothing to returnDELETE worked
400 Bad RequestYour request was malformedBad JSON, missing field
401 UnauthorizedCredentials missing or wrongAuth issue
403 ForbiddenYou’re authenticated but can’t do thisPermissions
404 Not FoundThe URL / resource doesn’t existWrong path
500 Internal Server ErrorThe device blew upDevice bug

The rule of thumb: 2xx = good. 4xx = your fault. 5xx = the device’s fault.

A working example — get all interfaces from an IOS-XE device

With curl

$ curl -k -u admin:cisco123 \
    -H "Accept: application/yang-data+json" \
    https://10.0.0.1/restconf/data/ietf-interfaces:interfaces

With Python

import requests
from requests.auth import HTTPBasicAuth

resp = requests.get(
    "https://10.0.0.1/restconf/data/ietf-interfaces:interfaces",
    auth=HTTPBasicAuth("admin", "cisco123"),
    headers={"Accept": "application/yang-data+json"},
    verify=False,        # ! test only — use proper certs in production
)

print(resp.status_code)
print(resp.json())

What the response looks like (JSON)

{
  "ietf-interfaces:interfaces": {
    "interface": [
      { "name": "GigabitEthernet0/0", "type": "iana-if-type:ethernetCsmacd", "enabled": true },
      { "name": "GigabitEthernet0/1", "type": "iana-if-type:ethernetCsmacd", "enabled": false }
    ]
  }
}

Parse with resp.json()["ietf-interfaces:interfaces"]["interface"] — done. No regex.

Configure a device with POST

Add a VLAN to a Catalyst running RESTCONF:

import requests

requests.post(
    "https://10.0.0.1/restconf/data/Cisco-IOS-XE-vlan:vlan",
    auth=("admin", "cisco123"),
    headers={
        "Accept": "application/yang-data+json",
        "Content-Type": "application/yang-data+json",
    },
    json={"vlan-list": [{"id": 10, "name": "USERS"}]},
    verify=False,
)

If the response code is 201, the VLAN now exists on the switch. Verify with a show vlan brief over SSH or another GET.

Authentication

Three flavors you’ll meet:

  • Basic auth — username + password in every request. Simple. Used by most Cisco platforms for CCNA-level demos.
  • API tokens — generate a token once, send it as a header on every request. Used by Meraki, DNA Center, most modern Cisco platforms.
  • OAuth 2.0 — token-with-refresh dance, common in big platforms.

For CCNA-level prep, focus on basic auth and API tokens.

Common mistakes

  1. Sending Content-Type wrong. Posting JSON but forgetting Content-Type: application/json (or application/yang-data+json for RESTCONF). Device responds with 400 Bad Request.

  2. Reading the request body when the response code is non-2xx. Always check resp.status_code first. The body of a 4xx response often has the actual error message.

  3. verify=False in production. Disables HTTPS certificate validation. Fine in a lab; dangerous in production (man-in-the-middle attacks). Use proper certs.

  4. Hardcoding passwords in scripts. Use environment variables or a secrets manager. Hardcoded creds in a Git repo is a career-limiting move.

  5. Not handling 401/403 errors. Token expired? Permissions changed? Catch the error, refresh the token or log the issue.

  6. Polling instead of using webhooks. Cisco DNA Center and Meraki support webhooks — the device pushes you events instead of you polling every minute. Use them when available.

Lab to try tonight

  1. Spin up an IOS-XE device in CML or use a sandbox at devnetsandbox.cisco.com.
  2. Enable RESTCONF: (config)# restconf + ip http secure-server.
  3. From your laptop, send a GET to /restconf/data/ietf-interfaces:interfaces. Confirm you get JSON back.
  4. Send a POST to create a new loopback interface.
  5. GET again — verify the new interface appears.
  6. DELETE the loopback. GET again — verify it’s gone.
  7. Bonus: write a Python script that bulk-shuts every interface that hasn’t seen traffic in 30 days (real ops automation).

Cheat strip

ConceptPlain English
RESTAn architectural style for HTTP APIs
GET / POST / PUT / DELETERead / create / replace / remove
2xx / 4xx / 5xxSuccess / your fault / server fault
JSON / XMLThe two body formats. Prefer JSON.
RESTCONFThe Cisco-flavored REST API standard for network gear
NETCONFAn older, XML-based API still widely used. Mentioned in CCNA exam topics.
API tokenAn auth credential sent as a header — more secure than basic auth
verify=FalseDisables HTTPS cert validation. Lab use only.
Master this on a real network

Want this drilled into reflex?

1:1 weekly sessions, live feedback on your labs, and US interview prep — built around the CCNA® exam blueprint. Free first session. No card on file until you decide.

Claim my free session →

One topic per email, every fortnight

VLANs, OSPF, ACLs, subnetting, automation — written like this. Unsubscribe in one click.

We respect your inbox. One email per week, max. Unsubscribe any time.

Start typing — or browse popular topics below.

↑↓ navigate open Searches topics · labs · programs · pages