Python is one of many programming languages that is widely used for automating networks. There is no built-in REST or HTTP client in Python, but Python allows importing libraries, functions, modules, or frameworks. One of the libraries that can be used to send HTTP REST API requests is the requests
library—an Apache2 Licensed HTTP library written in Python. In this recipe, we will import and leverage the requests
library to perform a REST API call to NSX in Python version 2.7.
- Make sure you have Python and the
requests
library installed. Python comes pre-installed on many Linux/Unix operating systems. If you do not have Python installed, head over to https://www.python.org/downloads/ to obtain it. - Once Python has been confirmed as installed and available, you can then verify the installation of the
Requests Python
module. One way to installRequests
is throughpip
using thepip install requests
command.