> ## Documentation Index
> Fetch the complete documentation index at: https://algolia.com/llms.txt
> Use this file to discover all available pages before exploring further.

# List indices

> Get a list of indices with their associated metadata.

export const Legacy = ({title, href}) => {
  return <Note>

    This page documents an earlier version of the API client.
    For the latest version, see <a href={href}>{title}</a>.

    </Note>;
};

<Legacy title="List indices" href="/doc/libraries/sdk/methods/search/list-indices" />

**Required ACL:** `listIndexes`

This method **retrieves a list of all indices** associated with a given application ID.

The returned list includes the names of the indices as well as their associated metadata, such as the number of records, size, and last build time.

The list of indices follows any ACL restrictions of the API key used to retrieve it.
For example, if you call this method with an API key that can only access some indices, you will only retrieve records from those.

## Examples

<CodeGroup>
  ```cs C# theme={"system"}
  // Use an API key with `listIndexes` ACL
  var client = new SearchClient("YourApplicationID", "YourAPIKey");
  var indices = client.ListIndices().Items;

  // Asynchronous
  await client.ListIndicesAsync();
  ```

  ```go Go theme={"system"}
  // Use an API key with `listIndexes` ACL
  client := search.NewClient("YourApplicationID", "YourAPIKey")
  response, err := client.ListIndices()
  indices := response.Items
  ```

  ```java Java theme={"system"}
  // Use an API key with `listIndexes` ACL
  SearchClient client = DefaultSearchClient.create("YourApplicationID", "YourAPIKey");
  List<IndicesResponse> indices = client.listIndices();

  // Asynchronous
  client.listIndicesAsync();
  ```

  ```js JavaScript theme={"system"}
  const algoliasearch = require('algoliasearch');

  // Use an API key with `listIndexes` ACL
  const client = algoliasearch('YourApplicationID', 'YourAPIKey');
  client.listIndices().then(({ items }) => {
    console.log(items);
  });
  ```

  ```kotlin Kotlin theme={"system"}
  // Use an API key with `listIndexes` ACL
  val client = ClientSearch(
    ApplicationID("YourApplicationID"),
    APIKey("YourAPIKey")
  )
  val indices = client.listIndices().items
  ```

  ```php PHP theme={"system"}
  <?php
  require_once __DIR__."/vendor/autoload.php";
  use Algolia\AlgoliaSearch\SearchClient;

  // Use an API key with `listIndexes` ACL
  $client = SearchClient::create(
    'YourApplicationID', 'YourAPIKey'
  );
  $indices = $client->listIndices()['items'];
  ```

  ```python Python theme={"system"}
  from algoliasearch.search_client import SearchClient

  # Use an API key with `listIndexes` ACL
  client = SearchClient.create("YourApplicationID", "YourAPIKey")
  indices = client.list_indices()["items"]
  ```

  ```ruby Ruby theme={"system"}
  require 'algolia'

  # Use an API key with `listIndexes` ACL
  client = Algolia::Search::Client.create(
    'YourApplicationID', 'YourAPIKey'
  )

  indices = client.list_indexes[:items]
  ```

  ```scala Scala theme={"system"}
  // Use an API key with `listIndexes` ACL
  val client = new AlgoliaClient("YourApplicationID", "YourAPIKey")
  val indices: Indices = Await.result(
    client.execute(list indices), Duration.Inf
  )
  ```

  ```swift Swift theme={"system"}
  import AlgoliaSearchClient

  // Use an API key with `listIndexes` ACL
  let client = SearchClient(
    appID: "YourApplicationID",
    apiKey: "YourAPIKey"
  )

  client.listIndices { result in
    if case .success(let response) = result {
      print("Response: \(response)")
    }
  }
  ```
</CodeGroup>

## Parameters

This method doesn't accept any input parameters.

## Response

<ResponseField name="items" type="object[]">
  <Expandable>
    <ResponseField name="createdAt" type="string">
      Index creation date. An empty string means that the index has no records.
    </ResponseField>

    <ResponseField name="dataSize" type="integer">
      Number of bytes of the index in minified format.
    </ResponseField>

    <ResponseField name="entries" type="integer">
      The number of records  in the index.
    </ResponseField>

    <ResponseField name="fileSize" type="integer">
      Number of bytes of the index binary file.
    </ResponseField>

    <ResponseField name="lastBuildTimeS" type="integer">
      Last build time in seconds.
    </ResponseField>

    <ResponseField name="name" type="string">
      Index name.
    </ResponseField>

    <ResponseField name="numberOfPendingTasks" type="integer" deprecated>
      The number of pending indexing operations.
    </ResponseField>

    <ResponseField name="pendingTask" type="boolean" deprecated>
      A boolean which is `true` if the index has pending tasks.
    </ResponseField>

    <ResponseField name="primary" type="string">
      If the index is a replica, this field has the name of the related primary index.
      This field is absent for primary indices.

      **Go only:** `primary` is an empty string for primary indices.
    </ResponseField>

    <ResponseField name="replicas" type="string[]">
      If the index is a primary index, this field has the names of all related replica indices.
      This field is absent for replica indices.
    </ResponseField>

    <ResponseField name="updatedAt" type="string">
      Date of the last update. An empty string means that the index has no records.
    </ResponseField>
  </Expandable>
</ResponseField>

<ResponseField name="nbPages" type="integer">
  The value is always 1. There is no pagination for this method.
  All indices are returned on the first call.
</ResponseField>

### Response as JSON

This section shows the JSON response returned by the API.
Each API client wraps this response in language-specific objects, so the structure may vary.
To view the response, use the `getLogs` method.
Don't rely on the order of properties—JSON objects don't preserve key order.

```jsonc JSON icon=braces theme={"system"}
{
  "items": [
    {
      "name": "movies",
      "createdAt": "2022-09-19T16:36:44.471Z",
      "updatedAt": "2022-09-19T18:02:30.996Z",
      "entries": 100,
      "dataSize": 48450,
      "fileSize": 112927,
      "lastBuildTimeS": 3,
      "numberOfPendingTasks": 0,
      "pendingTask": false
    }
  ],
  "nbPages": 1
}
```
