> ## 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 API keys

> Get a list of API keys.

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 API keys" href="/doc/libraries/sdk/methods/search/list-api-keys" />

**Required ACL:** `Admin`

## Examples

### List existing keys

<CodeGroup>
  ```cs C# theme={"system"}
  var keys = client.ListApiKeys();

  // Asynchronous
  var keys = await client.ListApiKeysAsync();
  ```

  ```go Go theme={"system"}
  res, err := client.ListAPIKeys()
  ```

  ```java Java theme={"system"}
  // Sync version
  List<ApiKey> apiKeys = client.listApiKeys();

  // Async version
  CompletableFuture<List<ApiKey>> apiKeys = client.listApiKeysAsync();
  ```

  ```js JavaScript theme={"system"}
  client.listApiKeys().then(({ keys }) => {
    console.log(keys);
  });
  ```

  ```kotlin Kotlin theme={"system"}
  client.listAPIKeys()
  ```

  ```php PHP theme={"system"}
  $client->listApiKeys();
  ```

  ```python Python theme={"system"}
  # Lists API Keys
  client.list_api_keys()
  ```

  ```ruby Ruby theme={"system"}
  # Lists API Keys
  client.list_api_keys
  ```

  ```scala Scala theme={"system"}
  //global
  client.execute {
    list keys
  }
  ```

  ```swift Swift theme={"system"}
  client.listAPIKeys { result in
    if case .success(let response) = result {
    }
  }
  ```
</CodeGroup>

## Parameters

This method doesn't accept any input parameters.

## Response

<ResponseField name="keys" type="object[]">
  <Expandable>
    <ResponseField name="acl" type="string[]">
      Set of permissions associated with the key.

      The possible access controls are:

      * **Search** (`search`): allowed to perform search operations.
      * **Browse Index** (`browse`): allowed to retrieve all index data with the `browse` endpoint.
      * **Add records** (`addObject`): allowed to add or update records in the index.
      * **Delete records** (`deleteObject`): allowed to delete an existing record.
      * **List indices** (`listIndexes`): allowed to get a list of all existing indices.
      * **Delete index** (`deleteIndex`): allowed to delete an index.
      * **Get index settings** (`settings`): allowed to read all index settings.
      * **Set index settings** (`editSettings`): allowed to update all index settings.
      * **Use analytics API** (`analytics`): allowed to retrieve data with the Analytics API.
      * **Use personalization API** (`recommendation`): allowed to interact with the Personalization API.
      * **Use usage API** (`usage`): allowed to retrieve data with the Usage API.
      * **Access logs** (`logs`): allowed to query the logs.
      * **Get unretrievable attributes** (`seeUnretrievableAttributes`): allowed to retrieve [`unretrievableAttributes`](/doc/api-reference/api-parameters/unretrievableAttributes) for all operations that return records.
    </ResponseField>

    <ResponseField name="createdAt" type="number">
      The timestamp at which the key has been created.

      Since admin API keys don't have a creation date, this field isn't returned for admin API keys.
    </ResponseField>

    <ResponseField name="description" type="string">
      Description for the key. This field isn't returned when the description is empty.
    </ResponseField>

    <ResponseField name="indexes" type="string[]">
      The list of targeted indices. This field isn't returned when empty.
    </ResponseField>

    <ResponseField name="maxHitsPerQuery" type="integer">
      Maximum number of hits this API key can retrieve in one query.

      If zero, no limit is enforced and the field is not returned.
    </ResponseField>

    <ResponseField name="maxQueriesPerIPPerHour" type="integer">
      Maximum number of API calls per hour allowed from a given IP address or a user token.

      Each time an API call is performed with this key, a check is performed.
      If the IP address or the user token at the origin of the call made more than the specified number of queries within the last hour, the API returns a 429 (Too Many Requests) status code.

      If zero, the field is not returned.
    </ResponseField>

    <ResponseField name="queryParameters" type="string">
      List query parameters that are applied for each query made with this API key.

      If empty, the field is not returned and no query parameters are applied.
    </ResponseField>

    <ResponseField name="referers" type="string[]">
      Lists referrer restrictions for this API key.
      Leading or trailing asterisks (`*`) indicate wildcards.

      For example:

      * `https://algolia.com/*` allows all referrers starting with `https://algolia.com/`
      * `*.algolia.com` allows all referrers ending with `.algolia.com`
      * `*algolia.com*` allows the whole domain `algolia.com`

      If empty, this field isn't returned and all referrers are allowed.
    </ResponseField>

    <ResponseField name="validity" type="integer">
      Timestamp of the date at which the key expires. A value of `0` means the key never expires.
    </ResponseField>

    <ResponseField name="value" type="string">
      The API key.
    </ResponseField>
  </Expandable>
</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"}
{
  "keys": [
    {
      "value": "0eb3e6308abccdf9b67d70ddacb418b4",
      "createdAt": 1513462891,
      "acl": ["search"],
      "validity": 0
    },
    {
      "value": "90dff5755e694f341fe68aaf6e41a6d4"
      "createdAt":1470244596,
      "acl":["search"],
      "validity":0,
      "description": "Search-only API Key"
    },
    {
      "value": "d6a23f212331969e41493051ede9865f",
      "createdAt": 1513610838,
      "acl": ["search"],
      "validity": 0
    }
  ]
}
```
