API Fundamentals Lab

Estimated Time: 40 minutes.

Objective

Humans speak to humans, humans speak to machines, but how do machines speak to machines? Using APIs! The purpose of this lab is to help you understand what APIs are, the basics of how they work, and why they are useful.

The Lab Journey

In this lab we are going to look at a few API basics that will set the foundations for future labs. We will cover:

- What an API is and why we use them

- Different API types

- An In-depth look at the RESTful API architecture

- HTTP REST verbs

- HTTP response codes

- Response payloads

If you are comfortable with RESTful APIs you may want to skip this theory lab and jump to the next one, API Authentication.

What is an API?

An API, or Application Programming Interface, is a standardized way for different applications, systems, and devices to share data and information with each other. The Apstra API allows customers to interact with it by asking it questions or telling it to do something. For example, a customer might ask the Apstra API for information about deployed switches, or instruct it to create a new VRF. This interaction follows a client-server model, where the client (such as a script, ticketing system, or command line window) initiates the request and the server (in this case, the Apstra API) responds with the requested information. Essentially, the API serves as a communication channel between the client and the server.

API in human speak

Why use APIs?

There are two main reasons why APIs are commonly used in the real world:

  1. Integration with internal and external systems: APIs allow different applications, systems, and devices to communicate with each other and share data, making it easier to integrate them into a larger system. This can be useful for things like connecting a CRM system to an accounting system, or integrating a network management tool with a monitoring system.

  2. Automating tasks: APIs can be used to automate tasks that would normally require a user to interact with a graphical user interface (GUI). For example, an API could be used to automate the process of provisioning a new user account or creating a report. This can save time and reduce the risk of errors.

Overall, APIs are used to facilitate communication and integration between different systems, and to automate tasks that would otherwise require manual intervention.

Integration with other systems

In an organization, there may be multiple systems that are used to manage the network, such as a ticket management system, an IP address management tool, or an analytics collector. By using the Apstra API, these systems can be integrated to create a more streamlined, automated network management experience. For example, suppose you want to open a ticket to deploy a VRF that will support a new business application. By integrating the ticket management system and Apstra via their APIs, you can create a program that automatically triggers the creation of the VRF when the ticket is opened, saving time and eliminating the need for manual intervention. This is just one example of how APIs can be used to facilitate communication and integration between different systems, improving efficiency and automating tasks.

Check out this recording of a previous Network Field Day where Apstra, Service Now and Slack were integrated to deploy and monitor data centers.

Automating GUI based tasks

Adding a new virtual network (VXLAN) in a data center can be a time-consuming task, especially if you have to do it multiple times. Using the Apstra web interface, it might take an engineer around 60 seconds to add a single virtual network. However, if you need to add 1000 virtual networks for a tenant, this task becomes much more tedious and prone to errors. This is not because people are incapable of doing it, but rather because humans can get distracted, tired, or complacent when performing repetitive tasks.

On the other hand, computers are very good at executing tasks over and over with 100% accuracy. By using a simple script and the Apstra API, a network administrator could create thousands of virtual networks in just a few seconds. This not only saves time, but also ensures that the virtual networks are created correctly, without any errors.

To calculate the time saved using the API, we can do the following calculation: 60 seconds x 1000 virtual networks = 1000 minutes minutes, which is nearly 17 hours. If you need to perform this task once a month, the time savings really start to add up. Overall, using APIs and automation can greatly improve efficiency and reduce the risk of errors when performing tasks in a data center.