Get API key permissions
This is documentation for v3 of the PHP API clients, which is not the latest version. To see the documentation for the latest version, see PHP v4.
This is documentation for v2 of the Ruby API clients, which is not the latest version. To see the documentation for the latest version, see Ruby v3.
This is documentation for v4 of the JavaScript API clients, which is not the latest version. To see the documentation for the latest version, see JavaScript v5.
This is documentation for v3 of the Python API clients, which is not the latest version. To see the documentation for the latest version, see Python v4.
This is documentation for v8 of the Swift API clients, which is not the latest version. To see the documentation for the latest version, see Swift v9.
This is documentation for v2 of the Kotlin API clients, which is not the latest version. To see the documentation for the latest version, see Kotlin v3.
This is documentation for v6 of the C# API clients, which is not the latest version. To see the documentation for the latest version, see C# v7.
This is documentation for v3 of the Java API clients, which is not the latest version. To see the documentation for the latest version, see Java v4.
This is documentation for v3 of the Go API clients, which is not the latest version. To see the documentation for the latest version, see Go v4.
This is documentation for v1 of the Scala API clients, which is not the latest version. To see the documentation for the latest version, see Scala v2.
Required API Key: Any
$client->getApiKey(apiKey)
You’re currently reading the JavaScript API client v4 documentation. Check the migration guide to learn how to upgrade from v3 to v4. You can still access the v3 documentation.
You’re currently reading the Ruby API client v2 documentation. Check the migration guide to learn how to upgrade from v1 to v2. You can still access the v1 documentation.
About this method
Get the permissions of an API key.
The scope of the permissions you can see is different when you initialize the search client with an Admin API key.
When initializing the client using the admin API key, you can request information for any of your application’s API keys.
When using a non-administrator API key, you can only retrieve information relating to that specific API key, and the description will be obfuscated for security purposes, its contents replaced by <redacted>
.
Examples
Read the Algolia CLI documentation for more information.
To get the permissions of a given key:
1
2
// Get the rights of a key
$res = $client->getApiKey('YourSearchOnlyAPIKey');
Parameters
apiKey
|
type: string
default: no default
Required
API Key to retrieve permissions for |
Response
This section shows the JSON response returned by the API.
Each API client encapsulates this response inside objects specific to the programming language,
so that the actual response might be different.
You can view the response by using the getLogs
method.
Don’t rely on the order of attributes in the response, as JSON doesn’t guarantee the ordering of keys in objects.
JSON format
1
2
3
4
5
6
7
{
"value":"d6386f212331969e41493051ede9a25f",
"createdAt":1513610838,
"acl":["search"],
"validity":0,
"description": "my key description"
}
Field | Description |
---|---|
value
|
string
The API key. |
createdAt
|
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. |
acl
|
list
Set of permissions associated with the key. The possible access controls are:
|
validity
|
integer
Timestamp of the date at which the key expires. A value of |
indexes
|
list
The list of targeted indices. This field isn’t returned when empty. |
description
|
string
Description of the key. This field isn’t returned when the description is empty. |
maxHitsPerQuery
|
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. |
maxQueriesPerIPPerHour
|
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—or the user-token if it’s set—at the origin of the call did more than the specified number of calls within the last hour, the API returns a 429 (Too Many Requests) status code. If zero, the field is not returned. |
queryParameters
|
URL-encoded query string
Force some query parameters to be applied for each query made with this API key.
You can force all query parameters like: If empty, the field is not returned. |
referers
|
list
Restrict this new API key to specific referers. If empty or blank, defaults to all referers.
You can specify a pattern with either a leading or trailing wildcard ( For example, If empty, the field is not returned. |