# How to get cluster health using python API?

**URL:** <https://discuss.elastic.co/t/how-to-get-cluster-health-using-python-api/25431>\
**Category:** Elasticsearch\
**Created:** [July 13, 2015, 10:02am UTC](https://discuss.elastic.co/t/how-to-get-cluster-health-using-python-api/25431 "2015-07-13T10:02:56Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![tobmei05](https://avatars.discourse-cdn.com/v4/letter/t/b4bc9f/32.png) [@tobmei05](https://discuss.elastic.co/u/tobmei05)\
**Post date:** [July 13, 2015, 10:02am UTC](https://discuss.elastic.co/t/how-to-get-cluster-health-using-python-api/25431/1 "2015-07-13T10:02:56Z")

</div>

Hi all

I want to get the health of an elasticsearch cluster similar to the command

```
curl -XGET 'http://localhost:9200/_cluster/health?pretty=true'

```

but using python. I did the following

```
from elasticsearch.client import ClusterClient
esc = ClusterClient([{'host': 'localhost', 'port': 9200}])
esc.health();

```

but all I get is an

```
AttributeError: 'list' object has no attribute 'transport'

```

I played around with some parameters for health() such us _index_ and _level_ but I mess around the syntax. Has someone a working example?

Regards,  
Tobi

---

<div class="post-metadata">

**Author:** ![tobmei05](https://avatars.discourse-cdn.com/v4/letter/t/b4bc9f/32.png) [@tobmei05](https://discuss.elastic.co/u/tobmei05)\
**Post date:** [July 14, 2015, 4:57am UTC](https://discuss.elastic.co/t/how-to-get-cluster-health-using-python-api/25431/2 "2015-07-14T04:57:41Z")

</div>

Got the answer from [stackoverflow](http://stackoverflow.com/questions/31391422/how-to-get-health-of-an-elasticsearch-cluster-using-python-api):

```
from elasticsearch import Elasticsearch
es = Elasticsearch()
print(es.cluster.health())

```

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 6, 2017, 12:01am UTC](https://discuss.elastic.co/t/how-to-get-cluster-health-using-python-api/25431/3 "2017-07-06T00:01:40Z")

</div>


