Every time I talk to users, there’s always one consistent theme: learning to use vSphere’s APIs is difficult. With the new release of vSphere 6.5, we’ve taken aim at improving that experience with the API Explorer. The API Explorer allows users to connect to the API endpoint and then browse and interact with available REST based APIs and their calls. This includes available parameters, expected responses, what response status codes may mean, and much more. If you’ve happened to use the Managed Object Browser, or MOB, think of that… but on steroids!
Accessing the API Explorer
Accessing the API Explorer is incredibly easy. It’s available on any API endpoint whether that be a vCenter server (appliance or Windows based) or external PSC appliance. Browse to: https://vcenter.fqdn/apiexplorer
After having loaded the API Explorer’s interface, it’s time to start looking around and seeing what’s available. There are two items that should jump out immediately, the login option and the “Select API” dropdown.
If you want to really interact with the API itself, you should log in. The login prompt accepts SSO based credentials, similar to what would be used to log into the vSphere client itself.
The “Select API” dropdown box allows the selection of available API. The APIs available on the endpoint are dependent upon the role the endpoint has.
Example: an External PSC appliance won’t have the same APIs and calls available to it as does the vCenter Server appliance.
- Appliance – handles calls to the underlying VMware appliance
- CIS – Common Infrastructure Services, handles calls involving tagging
- Content – handles calls involves the Content Library
- vAPI – vSphere API, handles calls regarding the API endpoint
- vCenter – handles calls to involving the vCenter
Browsing the API Explorer
Let’s take a look around the API Explorer now that we have our bearings.
With the vcenter API selected, expand the “GET /vcenter/cluster” operation.
On the above screen, we can see the path to make the call and the method. However, the API Explorer also gives some other information such as the expected response class, parameters and potential response messages. Clicking on those items expands and collapses additional information. Here’s some examples:
API Explorer Example – Response Class
API Explorer Example – Cluster Filter Parameters
API Explorer Example – Response Messages
My favorite part is right below those areas, the “Try It Out!” button. Clicking on that button performs the operation directly within the browser. It then provides a bunch of information such as an example cURL statement, the request’s URL, as well as the request’s body, status code, and headers.
The API Explorer is a great way to orient to and discover vSphere’s REST based APIs. Not only does it provide lots of information and additional context around the API calls, it even helps users start making those calls.