Skip to main content

Constructor

The second argument is the base URL. Leave it alone unless you’re pointing at a non-production host.

Options

string
API token. Falls back to LIMITEM_TOKEN or LIMITEM_KEY.
string
required
Application namespace.
number
required
Requests allowed in the window.
string | number
required
Window size. A number is seconds. Strings: "30s", "5m", "1h", "1d".
string
Optional product. Becomes namespace.product.
string
default:"fixed-window"
fixed-window | sliding-window | token-bucket | leaky-bucket.
number
default:"800"
Abort the Limitem request after this many milliseconds.
boolean
default:"false"
When true, outages return allowed: false instead of failing open.

limiter.limit(identifier)

Consume one request for identifier.

Response

boolean
Whether this request is allowed.
boolean
Same as allowed. Kept for older Contiguity callers.
string
Effective namespace, including product if you set one.
number
The limit you configured.
number
Requests left in the current window.
number
Unix timestamp (seconds) when the window resets — meaning depends on the algorithm.
number
How many requests are in the window after this check.
string
Algorithm used.
boolean
Present when the SDK could not reach Limitem.
boolean
Present when the API failed open on its side.
number
Seconds to wait. Only on a 429 from the API.
object
{ success, processing_time_ms } from the API.