API Fundamentals Lab
Tools to make API calls
One missing part of the API puzzel, how do you actually make API requests to Apstra or any other system as a user. There are several API clients that can be used and a few options are shown below.
cURL
cURL is a command-line tool that is used to transfer data, including making requests to API endpoints. It is a free, open-source software project that can be found at https://curl.se/.
There are several reasons why you might choose to use cURL:
-
It is highly portable and can be used on almost any operating system or connected device.
-
It is useful for interacting with endpoints and testing API functionality.
-
It can be verbose, providing detailed information about what has been sent and received, which is helpful for debugging and learning.
Below is an example of a simple cURL request.
Python
In order to work with APIs in Python, you will need tools that will make those requests. In Python, the most common library for making requests and working with APIs is the requests library. The requests library isn’t part of the standard Python library, so you’ll need to install it to get started.
Using a programming langue such as Python is a great way of creating more complex API workflows where several requests are chained together to reach a certain outcome.
Below is an example of a simple request in Python. The result of running this small script would be Python printing the returned data to the console window.
Postman
Postman is a graphical user interface (GUI) based API client that simplifies the process of creating, sharing, testing, and documenting API requests. It is available for multiple platforms and can be downloaded for free. Postman is a useful tool for learning APIs, and Juniper Apstra maintains a public Postman workspace to showcase what can be achieved with the Apstra API.
Postman is freely available on multiple platforms and can be downloaded here.
Below is an example of the Postmna UI interface with a request and a response.