Skip to content

Usage

Terminal window
npm install @limitry/sdk
import { createClient } from "@limitry/sdk";
const limitry = createClient(); // reads LIMITRY_API_KEY

GET /v1/usage/standing

Every enabled limit on one subject — and on its shared subjects (shared, comma-separated kind:id, such as team:team_42) — with what is used, what is left and when it resets, exact as of now.

await limitry.usage.standing({
kind: "user",
id: "usr_123",
});
FieldDescription
kindstring, query, requiredThe subject's kind, as your checks send it.
idstring, query, requiredThe subject's id, as your checks send it.
sharedstring, queryShared subjects to include, comma-separated kind:id (up to 4).
More about this endpoint

For showing an end user where they stand: call it from your server with your key, never from a browser. Not a check: nothing is counted. A subject with no limit here answers an empty limits list.

GET /v1/usage/subjects

A limit’s subjects in its CURRENT window, most used first: units used, what is left, how many checks were denied — over when any were.

await limitry.usage.subjects({
limitId: "lim_3f0c…",
});
FieldDescription
limitIdstring, query, requiredThe limit.
limitnumber, queryHow many subjects, most used first: 1–200. Default 50.
More about this endpoint

Up to about a minute behind live checks.

GET /v1/usage

Units used, checks allowed and denied for one limit — across all subjects, or one (subjectKind + subjectId) — per hour or per day (UTC), every bucket in the range included.

await limitry.usage.query({
limitId: "lim_3f0c…",
});
FieldDescription
limitIdstring, query, requiredThe limit.
subjectKindstring, queryWith subjectId: one subject's usage, not every subject's.
subjectIdstring, queryWith subjectKind: one subject's usage.
fromstring, queryStart of the range (ISO 8601). Default: 30 days before to.
tostring, queryEnd of the range (ISO 8601). Default: now.
granularitystring, queryOne bucket per hour or per day (UTC). Default: day.
More about this endpoint

Up to about a minute behind live checks. Default: the last 30 days, by day.