PYTHON, JSON AND API’S – PART 2

In part one we figured out how to authenticate to the API. We can now start digging in to getting some data. A lot of API’s are documented right along with the API. Vertiv however decided to document their API via PDF document. It is pretty clear the commands and the results, just kind of a pain it’s not online with the API. That being said let’s start building out some of the URL’s we need to pull data. First we look to get the root API URL. More times than not it’s something like http://192.168.10.15/api/v1. In this case it’s no different. Our root (I call it base) URL is

Next we can check the documentation to see where the info we want is located. I like to grab something easy right off the bat to make sure everything is working as expected. In reviewing the API docs, I see we can grab some system information.

The URL to grab this information is at the 2.2.1 header, /system/info. For simplicity let’s assign a variable to that portion of the URL.

Our next step is to combine the two URL variables so we have a full URL to call.

That’s exactly what we are looking for. We now have our authentication token and a URL to call. Let’s try it and see what we get.

It works! Next up, grabbing the info we want and putting it in the format we want.