Article by Gianluca Bortoli

VMware API Tutorial

The VMware View client protocol consists of a set of instructions that a software acting as a client can use to communicate with a View Connection Server instance. The client can perform a POST request with a properly constructed XML payload, in order to retrieve useful information about the VDI environment (i.e. virtual desktops, published applications, available resources etc). Consequently, an XML response is generated and sent back to the client. The communication between the two actors takes place over HTTPS and requires cookies to be handled on the client-side.

The APIs’ implementation is updated every time a new version of VMware Horizon (aka the server-side) is released. In order to keep all of them tracked, the version attribute in the broker tag of the client request informs the server about the protocol version the client supports. This parameter is also useful for managing backward and forward compatibility in the different API versions.


A (simplified) flow chart of the steps a client needs to perform in order to talk to the server.

In order to better understand the key functionalities of the protocol depicted in the figure above, let’s get into a concrete example: one may want to retrieve the list of all desktops and applications (if any) the server can provide.

import requests as re
def auth():
    response ={,
    if response.status_code == 200:
        # store the cookie
        return response.cookie
        # catch error
        print('Bad auth!')
def get_vdi_resources(cookie):
    response ={,
    if response.status_code == 200:
        # request ok, retrieve info processing XML
        # in the response
        return process(response.text)
        # catch error
# actually do stuff
auth_cookie = auth()
resources = get_vdi_resources(auth_cookie)

Probably, the lines of code above better explain the workflow of these APIs. First, the client authenticates on the server providing the credentials in the xml_data (ie. username, password and domain stored in an XML formatted following the specifications). If the authentication request succedes, a cookie is retrieved from its response. Once the client owns the auth_cookie, it can perform any kind of interaction with the server.

In the example above, I asked the server for the list of the available virtual desktops and applications. Moreover, many actions can be performed, such as logging out a specific user, requesting a direct connection with the server rather then a tunnelled one, configuring server-side parameters and also directly connecting to a virtual desktop.

The main point a developer needs to take into consideration is that every data sent and received have a strict and properly XML format defined in the VMware API documentation. Unfortunately, this language isn’t the most handy way to deal with data, since it needs to be parsed, stored as a tree and finally traversed in order to retrieve the information we are looking for. For this purpose, the ElementTree XML APIs for python helped me keeping the code simple when dealing with XML encoding, decoding and traversal.

Leave a Reply

There is strength in numbers

Our dealers are able to leverage our technology and work with us to design the optimal solutions for you.


They have chosen Praim solutions