Skip to main content

client.KeyAvailability()

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.

Signature​

func (c *Client) KeyAvailability(ctx context.Context, key string) (*APIKeyResponse, error)

Arguments​

NameTypeRequiredDescription
ctxcontext.ContextyesCancels the request and sets its deadline.
keystringyesAPI Key

Query Parameters​

None.

Response​

*addresszen.APIKeyResponse. Fields the API may leave out or send as null are pointers. RawJSON() returns the body as received. See responses.

Errors​

An HTTP error returns *addresszen.APIError with the HTTP status, the API error code and the body; match it with errors.AsType. A transport failure returns the net/http error, wrapped. See error handling.

Example​

key-availability/main.gogo
package main

import (
"context"
"fmt"
"log"

addresszen "go.addresszen.com/sdk"
)

func main() {
client := addresszen.NewClient("ak_test")
res, err := client.KeyAvailability(context.Background(), "ak_test")
if err != nil {
log.Fatal(err)
}
fmt.Println("Available:", res.Result.Available)
fmt.Println("Context:", res.Result.Context)
}