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 "@ideal-postcodes/sdk";
Path Parameters
| Name | Type | Required | Description |
|---|---|---|---|
key | string | yes | API Key The API Key to retrieve. Begins ak_. |
Query Parameters
| Name | Type | Required | Description |
|---|---|---|---|
start | number | no | Start Timestamp A start date/time in the form of a UNIX Timestamp in milliseconds. E.g. 1418556452651 |
end | number | no | End Timestamp An end date/time in the form of a UNIX Timestamp in milliseconds. E.g. 1418556477882 |
tags | string | no | Tags 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". |
licensee | string | no | Licensee Key Uniquely identifies a licensee. |
Response Type
import type { KeyUsageResponse } from "@ideal-postcodes/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 { createIdpcClient, keyUsage } from "@ideal-postcodes/sdk";
export const example = async () => {
const client = createIdpcClient({
apiKey: "ak_test",
userToken: "uk_example",
});
const { data } = await keyUsage({
client,
path: { key: "ak_test" },
});
return data;
};