REST APIs, JSON, and YAML
Modern network devices expose REST APIs returning JSON. Configuration as code lives in YAML files. This chapter teaches the bare minimum to read and write both, plus a worked REST GET against a NetForge-like device.
Modern network devices expose REST APIs returning JSON. Configuration as code lives in YAML files. This chapter teaches the bare minimum to read and write both, plus a worked REST GET against a NetForge-like device.
REST = HTTP verbs against resources. GET retrieves, POST creates, PUT replaces, PATCH updates a part, DELETE removes. The response is usually JSON. Status codes follow HTTP: 2xx success, 3xx redirect, 4xx client mistake (401 = auth, 404 = missing), 5xx server error.
GET /restconf/data/interfaces/interface=Gi0%2F0
Authorization: Basic <base64>
Accept: application/yang-data+json
200 OK
{ "ietf-interfaces:interface": {
"name": "Gi0/0",
"enabled": true,
"ietf-ip:ipv4": { "address": [{ "ip": "10.0.0.1", "netmask": "255.255.255.0" }] }
}}Curly braces are objects (key-value pairs). Square brackets are arrays. Strings are quoted. Numbers and booleans are not. JSON is what most APIs return.
{
"hostname": "R1",
"interfaces": [
{ "name": "Gi0/0", "ip": "10.0.0.1", "prefix": 24, "up": true },
{ "name": "Gi0/1", "ip": "10.0.1.1", "prefix": 24, "up": false }
]
}1 more section in this chapter, plus a 3-question quiz.
You can see the title, summary, learning objectives and the opening sections. The rest of this chapter, like all of modules 2–8, comes with the Course & Lab Pass and All-Access Max. A free account opens Module 1: Network Foundations end-to-end and saves your labs — start there, no card required.
NetForge-AI is an independent educational platform and is not affiliated with, endorsed by, or sponsored by any networking vendor or certification body. All product names, protocols, and standards referenced are the property of their respective owners and are used for descriptive, educational purposes only.
Free account · no card required · compare plans any time