> ## Documentation Index
> Fetch the complete documentation index at: https://mintlify.com/get-convex/rate-limiter/llms.txt
> Use this file to discover all available pages before exploring further.

# Constants

> Time constants for rate limiting

The Convex Rate Limiter exports helpful time constants to make rate limit configurations more readable.

## Time Constants

All time constants are in milliseconds.

### SECOND

```typescript theme={null}
export const SECOND = 1000;
```

Represents one second (1,000 milliseconds).

**Example:**

```typescript theme={null}
import { SECOND } from "@convex-dev/rate-limiter";

const config = {
  kind: "token bucket",
  rate: 5,
  period: SECOND // 1000ms
};
```

***

### MINUTE

```typescript theme={null}
export const MINUTE = 60 * SECOND;
```

Represents one minute (60,000 milliseconds).

**Value:** `60000`

**Example:**

```typescript theme={null}
import { MINUTE } from "@convex-dev/rate-limiter";

const config = {
  kind: "token bucket",
  rate: 10,
  period: MINUTE // 60000ms
};
```

***

### HOUR

```typescript theme={null}
export const HOUR = 60 * MINUTE;
```

Represents one hour (3,600,000 milliseconds).

**Value:** `3600000`

**Example:**

```typescript theme={null}
import { HOUR } from "@convex-dev/rate-limiter";

const config = {
  kind: "fixed window",
  rate: 100,
  period: HOUR // 3600000ms
};
```

***

### DAY

```typescript theme={null}
export const DAY = 24 * HOUR;
```

Represents one day (86,400,000 milliseconds).

**Value:** `86400000`

**Example:**

```typescript theme={null}
import { DAY } from "@convex-dev/rate-limiter";

const config = {
  kind: "fixed window",
  rate: 1000,
  period: DAY // 86400000ms
};
```

***

### WEEK

```typescript theme={null}
export const WEEK = 7 * DAY;
```

Represents one week (604,800,000 milliseconds).

**Value:** `604800000`

**Example:**

```typescript theme={null}
import { WEEK } from "@convex-dev/rate-limiter";

const config = {
  kind: "fixed window",
  rate: 10000,
  period: WEEK // 604800000ms
};
```

***

## Usage in Rate Limits

These constants make rate limit configurations more readable and maintainable:

```typescript theme={null}
import { RateLimiter, SECOND, MINUTE, HOUR, DAY } from "@convex-dev/rate-limiter";
import { components } from "./_generated/api";

const rateLimiter = new RateLimiter(components.rateLimiter, {
  // 10 requests per second
  apiCalls: {
    kind: "token bucket",
    rate: 10,
    period: SECOND
  },
  // 100 messages per minute
  sendMessage: {
    kind: "token bucket",
    rate: 100,
    period: MINUTE,
    capacity: 20
  },
  // 1000 requests per hour
  apiHourly: {
    kind: "fixed window",
    rate: 1000,
    period: HOUR
  },
  // 10000 requests per day
  dailyQuota: {
    kind: "fixed window",
    rate: 10000,
    period: DAY
  }
});
```

## Combining Constants

You can combine or multiply constants for custom periods:

```typescript theme={null}
import { MINUTE, HOUR } from "@convex-dev/rate-limiter";

// 30 minutes
const thirtyMinutes = 30 * MINUTE;

// 6 hours
const sixHours = 6 * HOUR;

// 90 seconds
const ninetySeconds = 90 * SECOND;

const config = {
  kind: "token bucket",
  rate: 50,
  period: thirtyMinutes
};
```

<Note>
  All time constants are in milliseconds to match JavaScript's `Date.now()` and Convex's time units.
</Note>
