Skip to main content

key_availability

Availability

Returns public information on an API Key: whether it can be used right now (available), the search contexts the key is licensed for (contexts) and the context that best matches the caller's IP address (context).

The endpoint accepts API Keys (beginning ak_) and sub-licensed keys (beginning sl_), and needs no Management Key.

A key that exists but cannot be used, because it has no lookups left or has breached a limit, returns 200 with "available": false. An unknown or malformed key returns an error.

Supply a valid Management Key and the endpoint returns the key's private details instead, as GET /keys/{key}/details does. A Management Key that does not own the key is rejected.

Endpoint​

GET /keys/{key}

See the API reference for this endpoint.

Import​

from ideal_postcodes import IdealPostcodes

Call key_availability on the IdealPostcodes client. Path parameters are positional; query and body parameters are keyword-only.

Path Parameters​

NameTypeRequiredDescription
keystryesAPI Key The API Key to retrieve. Begins ak_.

Query Parameters​

None.

Response Type​

from ideal_postcodes.types import KeyAvailabilityResult

Errors​

Unsuccessful HTTP responses raise APIError or a subclass, with the HTTP status and the API error code and message. Connection failures and timeouts raise TransportError. Unexpected responses raise ProtocolError. All derive from ClientError. See error handling.

Example​

key_availability.pypython
from ideal_postcodes import IdealPostcodes

with IdealPostcodes("ak_test") as client:
availability = client.key_availability("ak_test")