Requirements
Install
npm install @throttlr/sdk
Initialize
Create a single instance of RateLimiter and reuse it across your application. Do not create a new instance per request.
import { RateLimiter } from "@throttlr/sdk";
export const limiter = new RateLimiter({
apiKey: process.env.THROTTLR_API_KEY!,
baseUrl: "https://repoapi-production-fcf8.up.railway.app/sdk",
});
Constructor Options
| Option | Type | Required | Description |
|---|
apiKey | string | ✅ | Your project’s API key from the dashboard |
baseUrl | string | ❌ | Override the API base URL (defaults to production) |
Never hardcode your API key in source code. Use environment variables.
Environment Setup
Add your key to .env:
THROTTLR_API_KEY=sk_live_your_key_here
And load it in your app:
import dotenv from "dotenv";
dotenv.config();