🎉 Try the public beta of the new docs site at algolia.com/doc-beta! 🎉
API client / Methods / API keys

Get secured API key remaining validity

Required API Key: Any secured API key
Method signature
SearchClient::getSecuredApiKeyRemainingValidity(apiKey)

We released a new version of the PHP API client in public beta. Read the beta documentation for more information.

We released a new version of the JavaScript API client in public beta. Read the beta documentation for more information.

We released a new version of the Java API client in public beta. Read the beta documentation for more information.

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

Retrieve the remaining validity of a secured API key in seconds.

This method takes a secured API key as a parameter and returns the amount of seconds left until the API key’s validUntil field expires. If the key is no longer valid, the method returns a negative number indicating the amount of seconds passed since the key expired.

If the API key has no validUntil restriction, this method raises an exception or an error depending on your client.

Examples

Read the Algolia CLI documentation for more information.

Get the remaining validity on a secured API key:

1
$remainingValidity = SearchClient::getSecuredApiKeyRemainingValidity('YourSecuredAPIkey');

Parameters

Parameter Description
apiKey
type: string
default: no default
Required

Secured API Key to retrieve remaining validity 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
15
Field Description
remaining
integer

The amount of seconds left until the API key’s validUntil field expires. If the key is no longer valid, the method returns a negative number indicating the amount of seconds passed since the key expired.

If the API key has no validUntil restriction, this method raises an exception or an error depending on your client.

Did you find this page helpful?