Chapter 10. Working with Network APIs

From Python, Go, and data formats to configuration templating with Jinja, we’ve explored key foundational technologies and skills that will make you a better network engineer. In this chapter, you’re going to put these skills to practical use and start to consume and communicate with various types of network device APIs to start automating your network.

As we introduced in Chapter 2, nowadays there are multiple options to interact with network platforms. Along with the traditional CLI and SNMP, we have new alternatives—from network-specific APIs (such as NETCONF, RESTCONF, and gNMI) to multipurpose APIs (such as HTTP-based ones or the Linux shell). Not every device supports all of these options, so understanding their capabilities will determine your automation options.

All interfaces are viable for automation, each one with its own pros and cons. The goal of this chapter is to introduce these APIs, showcasing how you can use them programmatically in Python and Go.

To best help you understand how to start interacting with networks programmatically, this chapter is organized into two sections:

Understanding network APIs

We examine the architecture and foundation of APIs, including RESTful and non-RESTful HTTP-based APIs, NETCONF, RESTCONF, and gRPC/gNMI. In each case, we introduce common tools used for testing and show how to use each one.

Automating using network APIs

We introduce some popular Python and Go libraries that allow you to ...

Get Network Programmability and Automation, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.