Skip to main content

keyUsage

Usage Stats

Reports the number of lookups a key consumed over a date range, as a total and a daily breakdown.

The range defaults to the last 21 days. start and end take UNIX timestamps in milliseconds, and end defaults to the current time. The maximum range is 90 days.

Query at most three tags at once.

Endpoint​

GET /keys/{key}/usage

See the API reference for this endpoint.

This operation needs a Management Key. Set it as userToken on the client, which sends it in the Authorization header. See setup.

Import​

import { keyUsage } from "@addresszen/sdk";

Path Parameters​

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

Query Parameters​

NameTypeRequiredDescription
startnumbernoStart Timestamp A start date/time in the form of a UNIX Timestamp in milliseconds. E.g. 1418556452651
endnumbernoEnd Timestamp An end date/time in the form of a UNIX Timestamp in milliseconds. E.g. 1418556477882
tagsstringnoTags A comma separated list of tags to query over. Useful if you want to specify the circumstances in which the request was made. If you specify multiple tags, the response comprises only requests that satisfy all of them. Searching "foo,bar" queries only requests tagged both "foo" and "bar".
licenseestringnoLicensee Key Uniquely identifies a licensee.

Response Type​

import type { KeyUsageResponse } from "@addresszen/sdk";

Errors​

HTTP errors throw an ApiError with the HTTP status and the API error code and message. Network failures and aborts reject with the runtime's native error. Pass throwOnError: false to get { data, error } instead. See error handling.

Example​

key-usage.tsts
import { createZenClient, keyUsage } from "@addresszen/sdk";

export const example = async () => {
const client = createZenClient({
apiKey: "ak_test",
userToken: "uk_example",
});
const { data } = await keyUsage({
client,
path: { key: "ak_test" },
});
return data;
};