Exploring vSphere 6.5 API-Part 3: Esxi Host

In last 2 post of this series, we learn about digging out info about datacenter,cluster and virtual machines.

In this post we will learn about API options available for Esxi hosts.

If you have missed earlier posts of this series, you can read them from here:

1: Exploring vSphere 6.5 API-Datacenter & Cluster

2: Exploring vSphere 6.5 API-Virtual Machines

Let’s get started with fetching info about esxi hosts.

1: List all hosts present in a vCenter

Following query will list all esxi hosts that are present across all cluster/datacenter which are there in a vcenter.

# curl -sik -H ‘Accept: application/json’ -H ‘vmware-api-session-id: 7c639fb1e988b4c59dd77adef4c5d06c’ -X GET https://vcentersrv01.alex.local/rest/vcenter/host







2: List all host in a specific datacenter

You can limit search of esxi host to specific datacenter by using filter.datacenters option

# curl -sik -H ‘Accept: application/json’ -H ‘vmware-api-session-id: 7c639fb1e988b4c59dd77adef4c5d06c’ -X GET

3: List all hosts in a specific cluster

# curl -sik -H ‘Accept: application/json’ -H ‘vmware-api-session-id: 7c639fb1e988b4c59dd77adef4c5d06c’ -X GET https://vcentersrv01.alex.local/rest/vcenter/host?filter.clusters=domain-c7


"value": [
"host": "host-35",
"name": "esxi04.alex.local",
"connection_state": "CONNECTED",
"power_state": "POWERED_ON"

4: Info about a particular host

# curl -sik -H ‘Accept: application/json’ -H ‘vmware-api-session-id: 7c639fb1e988b4c59dd77adef4c5d06c’ -X GET https://vcentersrv01.alex.local/rest/vcenter/host?filter.hosts=host-33


"value": [
"host": "host-33",
"name": "esxi03.alex.local",
"connection_state": "CONNECTED",
"power_state": "POWERED_ON"

5: List all standalone host

If you have hosts that are not part of any cluster and are added as standalone host, you can list them by using filter.standalone=true

# curl -sik -H ‘Accept: application/json’ -H ‘vmware-api-session-id: 7c639fb1e988b4c59dd77adef4c5d06c’ -X GET https://vcentersrv01.alex.local/rest/vcenter/host?filter.standalone=true

6: List all hosts that are connected

The below query will filter out those hosts which are currently in disconnected state in vCenter

# curl -sik -H ‘Accept: application/json’ -H ‘vmware-api-session-id: 7c639fb1e988b4c59dd77adef4c5d06c’ -X GET


7: Disconnect a host from the vCenter server.

POST https://vcentersrv01.alex.local/rest/vcenter/host/{host}/disconnect


# curl -sik -X GET -H ‘Accept: application/json’ -H ‘vmware-api-session-id: 7c639fb1e988b4c59dd77adef4c5d06c’ -X POST https://vcentersrv01.alex.local/rest/vcenter/host/host-28/disconnect

8: Connect to the host previously added to the vCenter server.

POST https://vcentersrv01.alex.local/rest/vcenter/host/{host}/connect

9: Remove a standalone host from the vCenter Server.

DELETE https://vcentersrv01.alex.local/rest/vcenter/host/{host}

I hope this post is informational to you. Feel free to share this on social media if it is worth sharing. Be sociable 🙂


About Alex Hunt

Hi All I am Manish Kumar Jha aka Alex Hunt. I am currently working in VMware Software India Pvt Ltd as Operations System Engineer (vCloud Air Operations). I have around 5 Years of IT experience and have exposure on VMware vSphere, vCloud Director, RHEL and modern data center technologies like Cisco UCS and Cisco Nexus 1000v and NSX. If you find any post informational to you please press like and share it across social media and leave your comments if you want to discuss further on any post. Disclaimer: All the information on this website is published in good faith and for general information purpose only. I don’t make any warranties about the completeness, reliability and accuracy of this information. Any action you take upon the information you find on this blog is strictly at your own risk. The Views and opinions published on this blog are my own and not the opinions of my employer or any of the vendors of the product discussed.
This entry was posted in Vmware. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s