Skip to content

CCNA course / See how automation fits in ยท Step 3 of 6

Guide: Network automation and APIsSwitch

Guide

Network automation and APIs: data formats, REST, NETCONF, Python and telemetry (CCNA and CCNP)

This guide explains the data formats, management approaches, API behavior, Python patterns, and IOS XE telemetry concepts used in the linked exam questions. Examples describe common protocol behavior; device support and available YANG models vary by platform and software release.

7 parts ยท video ยท 92 practice questions

Automation fundamentals

Cisco Catalyst Center API examples use JSON objects and arrays as API request and response data. Cisco IOS XE RESTCONF supports JSON or XML media types. Cisco describes Ansible playbooks as YAML files and describes Ansible as agentless for network devices, with IOS XE support over CLI and NETCONF.

NETCONF default port
TCP port 830
Token duration in platform guide
60 seconds
Token duration in API example
one hour
Expired token response
401

Cisco IOS XE RESTCONF is a stateless, HTTPS-based interface for CRUD operations on YANG-defined data. YANG models configuration and state data; it is not the transport. NETCONF uses XML and RPC messages over SSH. Cisco IOS XE uses TCP port 830 by default for NETCONF, and the port is configurable.

Cisco Catalyst Center APIs use token authentication: POST to /dna/system/api/v1/auth/token with HTTP Basic Authentication to obtain a token, then send it in the X-Auth-Token header on later requests. Cisco documentation differs by release: the 3.3.x platform guide says 60 seconds, while a Cisco API example says one hour. Check the documentation for the deployed release; an expired token returns 401 and requires requesting a new token. Its API can return a managed-device inventory with GET /dna/intent/api/v1/network-device. Catalyst Center event notifications can call a configured webhook when a selected event occurs, rather than requiring a client to repeatedly ask for event updates.

Device-based management means configuring devices individually. Cloud-based management uses a provider-hosted dashboard for supported devices. Controller-based management centralizes management; northbound REST APIs expose capabilities to applications and southbound interfaces connect to managed infrastructure. Automation-based management uses tools and APIs to repeat tasks across devices. Cisco describes Ansible as agentless for network devices, with YAML playbooks and support for IOS XE using CLI or NETCONF.

References (6)

JSON and structured data formats

Cisco Catalyst Center API examples use JSON objects with quoted keys and values, nested objects, arrays, and numeric or boolean values. In {"interface": {"name": "Gi0/1", "enabled": true, "mtu": 1500}}, name is a string, enabled is a boolean, and mtu is a number. An array is enclosed in square brackets. Cisco IOS XE RESTCONF supports XML or JSON media types; NETCONF encodes messages and data in XML.

Cisco describes Ansible playbooks as YAML files. Its IOS XE RESTCONF documentation uses application/yang-data+json and application/yang-data+xml media types. The protocol and endpoint determine the accepted format.

References (3)

Network management approaches

Device-based management configures devices individually. Cloud-based management places management in a hosted dashboard for supported devices. Controller-based management uses a central platform: northbound APIs expose functions to applications and southbound interfaces connect to devices. Automation-based management uses scripts and playbooks to repeat operations. Cisco describes Ansible as agentless for network devices and supports IOS XE using CLI and NETCONF.

References (2)

CCNP REST APIs and HTTP

Cisco IOS XE RESTCONF uses HTTPS methods on YANG-modelled resources. GET reads, POST creates a resource or invokes an operation, PUT creates or replaces a resource, PATCH applies edits, and DELETE removes a resource. Cisco maps RESTCONF to NETCONF operations: POST create, PUT create or replace, and PATCH edit-config operations. A successful RESTCONF POST that creates a resource returns 201 Created. The API root is /restconf; data resources use /restconf/data/ and operations use /restconf/operations/.

Successful RESTCONF POST
201 Created
RESTCONF API root
/restconf
Data resource path
/restconf/data/
Operations path
/restconf/operations/
A REST request with a token, as a 14 second clip. Watch on its own page

For a JSON response, send Accept: application/yang-data+json. For a JSON request body, send Content-Type: application/yang-data+json. The corresponding XML media type is application/yang-data+xml. Cisco Catalyst Center uses X-Auth-Token for subsequent calls after token generation. The token endpoint is /dna/system/api/v1/auth/token and uses Basic Authentication. Token duration varies across Cisco release documentation: the 3.3.x platform guide states 60 seconds, while a Cisco example states one hour, so verify the deployed release.

References (3)

CCNP NETCONF, RESTCONF and YANG

YANG models configuration and state data. A leaf contains one value, a leaf-list contains multiple scalar values, a list represents repeatable structured entries and can use key leaves, and a container groups child nodes. NETCONF is an XML-based RPC protocol; IOS XE uses SSH TCP port 830 by default, and the port can be changed. Cisco documents <get> for configuration and operational data, and <get-config> for configuration from a selected datastore. The <running> datastore is the active configuration. Candidate datastore availability is platform and release dependent; verify device capabilities.

NETCONF default port
SSH TCP port 830
Candidate datastore identity
ietf-datastores:candidate
RESTCONF data resource
/restconf/data
RESTCONF operations path
/restconf/operations/

RESTCONF exposes YANG-modeled data using HTTPS methods. RFC 8527 updates RFC 8040 and defines datastore resources at {+restconf}/ds/<datastore>. The namespace-qualified identity ietf-datastores:candidate selects the candidate configuration datastore, as defined by RFC 8342. Other datastore resources are optional, so use this candidate path only when the server supports it. The /restconf/data resource is not an explicit candidate selector. The API root is /restconf, data resources are under /restconf/data/, and operations are under /restconf/operations/. GET reads, POST creates or invokes an operation, PUT creates or replaces, PATCH applies edits, and DELETE removes. Use Accept: application/yang-data+json to request JSON and Content-Type: application/yang-data+json for a JSON request body; XML uses application/yang-data+xml.

Cisco describes Ansible as agentless for network devices: its YAML playbooks can manage IOS XE using CLI or NETCONF.

References (6)

CCNP Python scripting for network APIs

In Cisco's Catalyst Center Python example, response.json()['response'] accesses the returned list, item['id'] selects a field in a device object, and item['hostname'] selects another field. For the example resp = {"response": [{"id": "1", "name": "Dist-Switch-1", "status": "REACHABLE"}]}, resp["response"][0]["status"] selects "REACHABLE".

Cisco Catalyst Center examples use Python's requests library for HTTP calls. The authentication endpoint accepts Basic Authentication credentials; subsequent requests include the returned token in X-Auth-Token. Cisco's Catalyst Center API documentation says an expired token returns 401 and needs renewal. Cisco's example also shows requests.get() and response.json(). Cisco Code Exchange describes NAPALM as a Python library that provides a unified API for interacting with different router vendors.

References (3)

CCNP EEM and network telemetry

Cisco IOS XE EEM applets define an event trigger followed by actions. The event syslog pattern <regular-expression> trigger matches a syslog message, and event track <object-number> state <up|down> follows a tracked object's state. action <label> cli command "<IOS command>" runs a CLI command; action <label> mail sends an email, and action <label> syslog msg writes a message to syslog. The Cisco IOS XE guide lists applets, Tcl policies, and Python policies as policy options, with syntax and support varying by release.

For EEM troubleshooting, show event manager policy registered displays registered policies, and show event manager history events displays events that have been triggered. Cisco's IOS XE guide also documents the event syslog and CLI action syntax.

Model-driven telemetry streams YANG-modeled data to a collector. Applications subscribe to selected data items and subscriptions specify the requested data, timing, format, and receiver. Configured subscriptions are dial-out because the publisher initiates the connection; dynamic subscriptions are dial-in. IOS XE documents periodic and on-change subscriptions, and configured dial-out subscriptions can use gRPC. Check whether a specific data path supports on-change and verify platform and release support.

IOS XE
event manager applet link_alert
 event syslog pattern "LINK-3-UPDOWN"
 action 1.0 cli command "show ip interface brief"
 action 2.0 syslog msg "EEM handled link event"
show event manager policy registered
show event manager history events
References (2)

Check your understanding

Network automation and APIs: data formats, REST, NETCONF, Python and telemetry (CCNA and CCNP)

All 7 sections ยท no timer

Unlimited retries

Questions from every section are combined into one assessment. Answer them all correctly to complete the article.

Your completion saves in this browser. Sign in to sync it to your account.