Skip to content

Usage API

The usage endpoints, each in TypeScript, Python, the CLI and curl.

Terminal window
npm install @limitry/sdk
export LIMITRY_API_KEY="lim_test_…"

To pass the key yourself, use createClient({ apiKey: key }) in TypeScript or Limitry(api_key=key) in Python.

Scope: limits:read.

Lists a limit’s subjects in its current window, most used first.

import { createClient } from "@limitry/sdk";
// Uses the LIMITRY_API_KEY environment variable.
const limitry = createClient();
const result = await limitry.usage.subjects();
console.log(result);

Returns:

{
"limitId": "lmt_6f1c2a9e-4b7d-4e3a-9c5f-8d2b1a0e7c34",
"limitName": "AI budget",
"unit": "cents",
"amount": 200,
"window": "month",
"periodStart": "2026-11-01T00:00:00.000Z",
"resetsAt": "2026-12-01T00:00:00.000Z",
"range": null,
"subjects": [
{
"subject": {
"kind": "user",
"id": "user_123"
},
"used": 120,
"remaining": 80,
"refused": 2
}
]
}
Field Description
limitId string, query The limit's ID. Send this or limitName.
limitName string, query The limit's name, instead of its ID. It matches an active limit in this environment, exactly or else ignoring case.
period string, query A named range instead of from and to, in UTC: today, this_week or last_week (weeks start on Monday), this_month or last_month. A current one ends now.
from string, query The start of the range, in ISO 8601.
to string, query The end of the range, in ISO 8601. Default: now.
sort string, query used lists the most used first, and refused the most refused first. Default: used.
top number, query How many subjects to rank, up to 50. Default: 50. A concurrent limit ranks at most 25.
More about this endpoint

Each one shows the units used, what’s left and how many checks the limit refused. The amounts are exact, but a subject first checked in the last minute may not appear yet. For a concurrent limit, it lists the slots each subject holds now, among the subjects checked in the last hour. Name the limit by limitId or limitName. For a past range, send period, such as last_month, or from and to. The subjects are then ranked by their use in that range, from history. Each one’s remaining is then null. Set sort to refused to list the most refused first. The current window is whole on every plan. A past range reaches no further back than your plan’s history.

Scope: limits:read.

Returns one limit’s usage over time: the units used, and the checks allowed and refused, with the range’s total beside the buckets.

import { createClient } from "@limitry/sdk";
// Uses the LIMITRY_API_KEY environment variable.
const limitry = createClient();
const result = await limitry.usage.query();
console.log(result);

Returns:

{
"limitId": "lmt_6f1c2a9e-4b7d-4e3a-9c5f-8d2b1a0e7c34",
"limitName": "AI budget",
"unit": "cents",
"amount": 200,
"window": "month",
"granularity": "day",
"from": "2026-10-01T00:00:00.000Z",
"to": "2026-11-01T00:00:00.000Z",
"total": {
"used": 12480,
"allowed": 2396,
"refused": 214
},
"points": [
{
"start": "2026-10-05T00:00:00.000Z",
"used": 1250,
"allowed": 248,
"refused": 3
}
]
}
Field Description
limitId string, query The limit's ID. Send this or limitName.
limitName string, query The limit's name, instead of its ID. It matches an active limit in this environment, exactly or else ignoring case.
subject string, query One subject, as kind:id, to see its usage instead of every subject's.
period string, query A named range instead of from and to, in UTC: today, this_week or last_week (weeks start on Monday), this_month or last_month. A current one ends now.
from string, query The start of the range, in ISO 8601. Default: 30 days before to.
to string, query The end of the range, in ISO 8601. Default: now.
granularity string, query Whether each bucket is an hour or a day, in UTC. Default: day.
More about this endpoint

It covers every subject, or one subject named in subject as kind:id. Name the limit by limitId or limitName. Choose the range with period (such as last_month) or from and to. Usage comes in hourly or daily buckets in UTC, and the response includes every bucket in the range. It can be up to about a minute behind live checks. By default, it covers the last 30 days, by day. A request returns at most 2,000 buckets. Usage older than your plan’s history isn’t returned.

Scope: limits:read.

Returns every active limit’s usage in one answer, for a question that names no limit.

import { createClient } from "@limitry/sdk";
// Uses the LIMITRY_API_KEY environment variable.
const limitry = createClient();
const result = await limitry.usage.overview();
console.log(result);

Returns:

{
"range": {
"from": "2026-10-01T00:00:00.000Z",
"to": "2026-11-01T00:00:00.000Z"
},
"limits": [
{
"limitId": "lmt_6f1c2a9e-4b7d-4e3a-9c5f-8d2b1a0e7c34",
"limitName": "AI budget",
"unit": "cents",
"amount": 200,
"window": "month",
"periodStart": "2026-10-01T00:00:00.000Z",
"resetsAt": null,
"total": {
"used": 12480,
"allowed": 2396,
"refused": 214
},
"subjects": [
{
"subject": {
"kind": "user",
"id": "user_123"
},
"used": 200,
"remaining": null,
"refused": 6
}
],
"credits": {
"added": 500,
"takenBack": 0,
"latest": [
{
"subject": {
"kind": "user",
"id": "user_123"
},
"amount": 500,
"note": "Credit pack",
"createdAt": "2026-11-03T01:07:05.959Z"
}
]
}
}
]
}
Field Description
period string, query A named range instead of from and to, in UTC: today, this_week or last_week (weeks start on Monday), this_month or last_month. A current one ends now.
from string, query The start of the range, in ISO 8601.
to string, query The end of the range, in ISO 8601. Default: now.
sort string, query used lists each limit's most used subjects first, and refused only its refused subjects, the most refused first. Default: used.
top number, query How many subjects to list for each limit, up to 20. Default: 5.
More about this endpoint

Each limit comes with its name, unit, amount and window, its total (units used, checks allowed and refused) and its top subjects. By default, it covers each limit’s current window, with exact amounts. For a past range, send period, such as last_month, or from and to. The totals and subjects then come from history, and each subject’s remaining is null. Set sort to refused to list only the subjects each limit refused, the most refused first. A balance lists the credits added to it, and a limit that resets lists its top-ups. The current window is whole on every plan. A past range reaches no further back than your plan’s history.