The NX-API Sandbox is a single-page web app hosted directly on the Nexus 9000 series switch. This tool is very
useful if you are starting out learning how to programmatically interact with Nexus switches. It allows you to
take the CLI commands that you already know and convert them into either NX-API CLI payloads that are represented
as XML or JSON formats or NX-API REST payload equivalents.
Both NX-API variants utilize HTTP or HTTPS transports
for requests. NX-API CLI and NX-API REST vary slightly in the context of both being APIs. NX-API CLI uses either
the XML or JSON interfaces with each's respective data structures or through JSON-RPC 2.0. These two request
formats support elements to send or get data via POST requests. NX-API REST, on the other hand, is a standard
Representational State Transfer (REST) API that introduces an object model to the Nexus 9000 series standalone
switch.
The NX-API requests have a set of response elements as well. Responses have varying standard HTML response codes.
These can be found here:
NX-API HTML Response Codes.
You are probably familiar with some of them; 200 for success or 400/500 for errors.
As a user you need to enable the NX-API feature. This has been done for you in this lab as part of the bootstrap configuration using the following command:
feature nxapi
The default port used as of NX-OS 9.x is the HTTPS port 443. There are cli commands available to enable the HTTP port 80 or to change both of these default port numbers:
conf ; nxapi http port {port-number}
conf ; nxapi https port {port-number}
For the purpose of this lab, you are going to leave the ports with their respective defaults.
You can browse to the NX-API Sandbox using the management IP address of the Nexus 9000 series switch that has the NX-API feature enabled in your web browser. Using the HTTPS link below, browse to your first Leaf switch. You will only briefly use the NX-API Sandbox to get comfortable with requests to the switches and the data structures. In the next few sections you will see how you can leverage NX-API with Python and Ansible.
Login to the NX-API Sandbox by copying the URL below, opening a new tab in your browser, paste the URL in the new tab, and hit Enter/Return on your keyboard:
You may need to bypass Chrome's Self Signed certificate warning by typing thisisunsafe
anywhere in the browser
Login using your username and password for the Leaf switch:
You will be required to login using credentials that would permit you access to the CLI of the switch. Ignore the prompt asking you to save the username and password. Upon a successful login, your web browser page should look like the graphic below:
Continue to the next section to explore the NX-API CLI JSON API.