---
id: gh-upstash-ratelimit-js
name: "upstash-ratelimit-js"
url: https://skills.yangsir.net/skill/gh-upstash-ratelimit-js
author: upstash
domain: ai-dev-tools-workflow
tags: ["upstash", "ratelimit", "redis", "typescript", "sdk"]
install_count: 21300
rating: 4.60 (120 reviews)
github: https://github.com/upstash/skills/tree/main/skills/upstash-ratelimit-js
---

# upstash-ratelimit-js

> 提供使用 Upstash Redis RateLimit TypeScript/JavaScript SDK 的轻量级指导，包括安装、创建速率限制器、应用滑动窗口等算法。帮助开发者快速为应用添加可靠的速率限制功能，防止滥用和过载，简化开发流程。

**Stats**: 21,300 installs · 4.6/5 (120 reviews)

## Before / After 对比

### 实现速率限制效率对比

**Before**:

开发者需要手动编写 Redis Lua 脚本实现速率限制逻辑，并反复调试和验证正确性，常常花费大量时间。

**After**:

此技能提供了清晰的 SDK 文档和示例代码，开发者只需数行代码即可集成，大幅降低实现门槛。

| Metric | Before | After | Change |
|---|---|---|---|
| 实现时间 | 60分钟 | 10分钟 | -83% |

## Readme

# Rate Limit TS SDK

## Quick Start
- Install the SDK and connect to Redis.
- Create a rate limiter and apply it to incoming operations.

Example:
```ts
import { Ratelimit } from "@upstash/ratelimit";
import { Redis } from "@upstash/redis";

const redis = new Redis({ url: "<url>", token: "<token>" });
const limiter = new Ratelimit({ redis, limiter: Ratelimit.slidingWindow(5, "10s") });

const { success } = await limiter.limit("user-id");
if (!success) {
  // throttled
}
```

## Other Skill Files
- **algorithms.md**: Describes all available rate‑limiting algorithms and how they behave.
- **pricing-cost.md**: Explains pricing, Redis cost implications, and operational considerations.
- **features.md**: Lists SDK features such as prefixes, custom keys, and behavioral options.
- **methods-getting-started.md**: Full method reference for the SDK's API and getting started guide.
- **traffic-protection.md**: Guidance on applying rate limiting for traffic shaping, abuse prevention, and protection patterns.


---
*Source: https://skills.yangsir.net/skill/gh-upstash-ratelimit-js*
*Markdown mirror: https://skills.yangsir.net/api/skill/gh-upstash-ratelimit-js/markdown*