|  | 
|  | 1 | +--- | 
|  | 2 | +layout: default | 
|  | 3 | +title: List API | 
|  | 4 | +nav_order: 45 | 
|  | 5 | +has_children: true | 
|  | 6 | +--- | 
|  | 7 | + | 
|  | 8 | +# List APIs | 
|  | 9 | +**Introduced 2.18** | 
|  | 10 | +{: .label .label-purple } | 
|  | 11 | + | 
|  | 12 | +The List API retrieves statistics about indexes and shards in a paginated format. This streamlines the task of processing responses that include many indexes. | 
|  | 13 | + | 
|  | 14 | +The List API supports two operations: | 
|  | 15 | + | 
|  | 16 | +- [List indices]({{site.url}}{{site.baseurl}}/api-reference/list/list-indices/) | 
|  | 17 | +- [List shards]({{site.url}}{{site.baseurl}}/api-reference/list/list-shards/) | 
|  | 18 | + | 
|  | 19 | +## Shared query parameters | 
|  | 20 | + | 
|  | 21 | +All List API operations support the following optional query parameters. | 
|  | 22 | + | 
|  | 23 | +Parameter | Description | 
|  | 24 | +:--- | :--- | | 
|  | 25 | +`v` |  Provides verbose output by adding headers to the columns. It also adds some formatting to help align each of the columns. All examples in this section include the `v` parameter. | 
|  | 26 | +`help` | Lists the default and other available headers for a given operation. | 
|  | 27 | +`h`  |  Limits the output to specific headers. | 
|  | 28 | +`format` |  The format in which to return the result. Valid values are `json`, `yaml`, `cbor`, and `smile`. | 
|  | 29 | +`s` | Sorts the output by the specified columns. | 
|  | 30 | + | 
|  | 31 | +## Examples | 
|  | 32 | + | 
|  | 33 | +The following examples show how to use the optional query parameters to customize all List API responses. | 
|  | 34 | + | 
|  | 35 | + | 
|  | 36 | +### Get verbose output | 
|  | 37 | + | 
|  | 38 | +To query indexes and their statistics with a verbose output that includes all column headings in the response, use the `v` query parameter, as shown in the following example. | 
|  | 39 | + | 
|  | 40 | +#### Request | 
|  | 41 | + | 
|  | 42 | +```json | 
|  | 43 | +GET _list/indices?v | 
|  | 44 | +``` | 
|  | 45 | +{% include copy-curl.html %} | 
|  | 46 | + | 
|  | 47 | +#### Response | 
|  | 48 | + | 
|  | 49 | +```json | 
|  | 50 | +health status index           uuid    pri rep  docs.count  docs.deleted | 
|  | 51 | +green  open   .kibana_1 - - - -               | 
|  | 52 | +yellow open    sample-index-1 - - - - | 
|  | 53 | +next_token null | 
|  | 54 | +``` | 
|  | 55 | + | 
|  | 56 | + | 
|  | 57 | +### Get all available headers | 
|  | 58 | + | 
|  | 59 | +To see all the available headers, use the `help` parameter with the following syntax: | 
|  | 60 | + | 
|  | 61 | +```json | 
|  | 62 | +GET _list/<operation_name>?help | 
|  | 63 | +``` | 
|  | 64 | +{% include copy-curl.html %} | 
|  | 65 | + | 
|  | 66 | +#### Request | 
|  | 67 | + | 
|  | 68 | +The following example list indices operation returns all the available headers: | 
|  | 69 | + | 
|  | 70 | +```json | 
|  | 71 | +GET _list/indices?help | 
|  | 72 | +``` | 
|  | 73 | +{% include copy-curl.html %} | 
|  | 74 | + | 
|  | 75 | +#### Response | 
|  | 76 | + | 
|  | 77 | +The following example displays the indexes and their health status in a table: | 
|  | 78 | + | 
|  | 79 | +```json | 
|  | 80 | +health     | h                              | current health status | 
|  | 81 | +status     | s                              | open/close status | 
|  | 82 | +index      | i,idx                          | index name | 
|  | 83 | +uuid       | id,uuid                        | index uuid | 
|  | 84 | +pri        | p,shards.primary,shardsPrimary | number of primary shards | 
|  | 85 | +rep        | r,shards.replica,shardsReplica | number of replica shards | 
|  | 86 | +docs.count | dc,docsCount                   | available docs | 
|  | 87 | +``` | 
|  | 88 | + | 
|  | 89 | +### Get a subset of headers | 
|  | 90 | + | 
|  | 91 | +To limit the output to a subset of headers, use the `h` parameter with the following syntax: | 
|  | 92 | + | 
|  | 93 | +```json | 
|  | 94 | +GET _list/<operation_name>?h=<header_name_1>,<header_name_2>&v | 
|  | 95 | +``` | 
|  | 96 | +{% include copy-curl.html %} | 
|  | 97 | + | 
|  | 98 | +For any operation, you can determine which headers are available by using the `help` parameter and then using the `h` parameter to limit the output to only a subset of headers.  | 
|  | 99 | + | 
|  | 100 | +#### Request | 
|  | 101 | + | 
|  | 102 | +The following example limits the indexes in the response to only the index name and health status headers: | 
|  | 103 | + | 
|  | 104 | +```json | 
|  | 105 | +GET _list/indices?h=health,index | 
|  | 106 | +``` | 
|  | 107 | +{% include copy-curl.html %} | 
|  | 108 | + | 
|  | 109 | +### Response | 
|  | 110 | + | 
|  | 111 | +```json | 
|  | 112 | +green  .kibana_1 | 
|  | 113 | +yellow sample-index-1 | 
|  | 114 | +next_token null | 
|  | 115 | +``` | 
|  | 116 | + | 
|  | 117 | + | 
|  | 118 | +### Sort by a header | 
|  | 119 | + | 
|  | 120 | +To sort the output on a single page by a header, use the `s` parameter with the following syntax: | 
|  | 121 | + | 
|  | 122 | +```json | 
|  | 123 | +GET _list/<operation_name>?s=<header_name_1>,<header_name_2> | 
|  | 124 | +``` | 
|  | 125 | +{% include copy-curl.html %} | 
|  | 126 | + | 
|  | 127 | +#### Request | 
|  | 128 | + | 
|  | 129 | +The following example request sorts indexes by index name: | 
|  | 130 | + | 
|  | 131 | +```json | 
|  | 132 | +GET _list/indices?s=h,i | 
|  | 133 | +``` | 
|  | 134 | +{% include copy-curl.html %} | 
|  | 135 | + | 
|  | 136 | +#### Response | 
|  | 137 | + | 
|  | 138 | +```json | 
|  | 139 | +green sample-index-2 | 
|  | 140 | +yellow sample-index-1 | 
|  | 141 | +next_token null | 
|  | 142 | +``` | 
|  | 143 | + | 
|  | 144 | +### Retrieve data in JSON format | 
|  | 145 | + | 
|  | 146 | +By default, List APIs return data in a `text/plain` format. Other supported formats are [YAML](https://yaml.org/), [CBOR](https://cbor.io/), and [Smile](https://github.com/FasterXML/smile-format-specification). | 
|  | 147 | + | 
|  | 148 | + | 
|  | 149 | +To retrieve data in the JSON format, use the `format=json` parameter with the following syntax. | 
|  | 150 | + | 
|  | 151 | +If you use the Security plugin, ensure you have the appropriate permissions. | 
|  | 152 | +{: .note } | 
|  | 153 | + | 
|  | 154 | +#### Request | 
|  | 155 | + | 
|  | 156 | +```json | 
|  | 157 | +GET _list/<operation_name>?format=json | 
|  | 158 | +``` | 
|  | 159 | +{% include copy-curl.html %} | 
|  | 160 | + | 
|  | 161 | +#### Request | 
|  | 162 | + | 
|  | 163 | +```json | 
|  | 164 | +GET _list/indices?format=json | 
|  | 165 | +``` | 
|  | 166 | +{% include copy-curl.html %} | 
|  | 167 | + | 
|  | 168 | +### Response | 
|  | 169 | + | 
|  | 170 | +The response contains data in JSON format: | 
|  | 171 | + | 
|  | 172 | +```json | 
|  | 173 | +{"next_token":null,"indices":[{"health":"green","status":"-","index":".kibana_1","uuid":"-","pri":"-","rep":"-","docs.count":"-","docs.deleted":"-","store.size":"-","pri.store.size":"-"},{"health":"yellow","status":"-","index":"sample-index-1","uuid":"-","pri":"-","rep":"-","docs.count":"-","docs.deleted":"-","store.size":"-","pri.store.size":"-"}]} | 
|  | 174 | +``` | 
|  | 175 | + | 
0 commit comments