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 (subject, as kind:id, such as user:usr_123) — 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({
subject: "user:usr_123",
});
FieldDescription
subjectstring, query, requiredThe subject, as kind:id: its kind and id as your checks send them.
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, and how many checks it refused.

await limitry.usage.subjects({
limitId: "lmt_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 refused for one limit — across all subjects, or one (subject, as kind:id) — per hour or per day (UTC), every bucket in the range included.

await limitry.usage.query({
limitId: "lmt_3f0c…",
});
FieldDescription
limitIdstring, query, requiredThe limit.
subjectstring, queryOne subject's usage, not every subject's, as kind:id.
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.