# Get List of indices using Java Rest API

**URL:** https://discuss.elastic.co/t/get-list-of-indices-using-java-rest-api/70004
**Category:** Elasticsearch
**Created:** [December 26, 2016, 12:44pm UTC](https://discuss.elastic.co/t/get-list-of-indices-using-java-rest-api/70004 "2016-12-26T12:44:54Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![kumarroopesh](https://avatars.discourse-cdn.com/v4/letter/k/85f322/32.png) [@kumarroopesh](https://discuss.elastic.co/u/kumarroopesh)
#### Post date: [December 26, 2016, 12:44pm UTC](https://discuss.elastic.co/t/get-list-of-indices-using-java-rest-api/70004/1 "2016-12-26T12:44:54Z")

</div>

Hi,  
I am using Java REST APIs 5.1.1 for elasticsearch. I need to get the list of indexes on successful connection to elasticsearch using host, port, username, password.  
I am not able to get a list of available indexes.

Please help.

---

<div class="post-metadata">

### Author: ![andrewkroh](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/andrewkroh/32/3784_2.png) [@andrewkroh](https://discuss.elastic.co/u/andrewkroh)
#### Post date: [December 26, 2016, 3:35pm UTC](https://discuss.elastic.co/t/get-list-of-indices-using-java-rest-api/70004/2 "2016-12-26T15:35:22Z")

</div>

> [@kumarroopesh](#):
>
> I am not able to get a list of available indexes.

What have you tried? You can get a list of all indices with:

`curl -XGET "http://localhost:9200/_aliases"`

---

<div class="post-metadata">

### Author: ![kumarroopesh](https://avatars.discourse-cdn.com/v4/letter/k/85f322/32.png) [@kumarroopesh](https://discuss.elastic.co/u/kumarroopesh)
#### Post date: [December 27, 2016, 8:26am UTC](https://discuss.elastic.co/t/get-list-of-indices-using-java-rest-api/70004/3 "2016-12-27T08:26:33Z")

</div>

Hi @andrewkroh,

Sorry, it is my bad. Actually I got this command earlier. But I don't know how to call this using java rest APIs given.  
I am new in Java development. How to execute this from RestClient, or what is the way to call this and get result in java.

Thanks

---

<div class="post-metadata">

### Author: ![andrewkroh](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/andrewkroh/32/3784_2.png) [@andrewkroh](https://discuss.elastic.co/u/andrewkroh)
#### Post date: [December 27, 2016, 9:47pm UTC](https://discuss.elastic.co/t/get-list-of-indices-using-java-rest-api/70004/4 "2016-12-27T21:47:05Z")

</div>

Have you seen the examples [here](https://www.elastic.co/guide/en/elasticsearch/client/java-rest/current/_example_requests.html)?

```auto
Response response = restClient.performRequest("GET", "/_aliases",
        Collections.singletonMap("pretty", "true"));
System.out.println(EntityUtils.toString(response.getEntity()));

```

Then you need to unmarshal the response.

---

<div class="post-metadata">

### Author: ![kumarroopesh](https://avatars.discourse-cdn.com/v4/letter/k/85f322/32.png) [@kumarroopesh](https://discuss.elastic.co/u/kumarroopesh)
#### Post date: [December 28, 2016, 6:38am UTC](https://discuss.elastic.co/t/get-list-of-indices-using-java-rest-api/70004/5 "2016-12-28T06:38:06Z")

</div>

Thanks @andrewkroh,  
It worked.  
Though I have been through the example requests page, but I think I missed that EntityUtils thing.

Thanks again.  
🙂

---

<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: [January 25, 2017, 6:38am UTC](https://discuss.elastic.co/t/get-list-of-indices-using-java-rest-api/70004/6 "2017-01-25T06:38:22Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
