Home > Blogs > VMware Developer Blog > Monthly Archives: January 2017

Monthly Archives: January 2017

The Developer Blog Has Moved!

Developer Center is now VMware {code} and we have a new blog at blogs.vmware.com/code. Here you will find the latest and greatest tips, tutorials, and news for developers on a wide range of topics from vSphere and PowerCLI to DevOp and cloud-native apps.

This blog will remain alive as an archive so you can refer back to old posts you may have bookmarked. Thanks for reading!

Visit the new website: https://code.vmware.com/

Follow us on Twitter: https://twitter.com/vmwarecode

Questions or feedback? Email us at code@vmware.com

API Explorer Main Screen

Getting Started with vSphere’s API Explorer

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

API Explorer Main Screen

First Look

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.

Common APIs:

  • 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.

API Explorer - Cluster Operations

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 – Response Class

API Explorer Example - Cluster Filter Parameters

API Explorer Example – Cluster Filter Parameters

API Explorer Example - Response Messages

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.

API Explorer Example - Try It Out

Conclusion

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.