Rate Limit Pro

Advanced rate limiting with tiered controls and quota management

Safety Notice

This listing is from the official public ClawHub registry. Review SKILL.md and referenced scripts before running.

Copy this and send it to your AI assistant to learn

Install skill "Rate Limit Pro" with this command: npx skills add raghulpasupathi/rate-limit-pro

Rate Limit Pro

Advanced rate limiting with multiple tiers and quota management.

Implementation

class RateLimiter {
  constructor(options = {}) {
    this.tiers = options.tiers || {
      free: { requests: 10, window: 60000 }, // 10 req/min
      basic: { requests: 100, window: 60000 },
      pro: { requests: 1000, window: 60000 }
    };
    this.requests = new Map();
  }

  checkLimit(userId, tier = 'free') {
    const tierConfig = this.tiers[tier];
    if (!tierConfig) {
      return { allowed: false, reason: 'invalid_tier' };
    }

    const now = Date.now();
    const userRequests = this.requests.get(userId) || [];

    // Remove old requests outside window
    const validRequests = userRequests.filter(
      timestamp => now - timestamp < tierConfig.window
    );

    // Check if under limit
    if (validRequests.length >= tierConfig.requests) {
      const oldestRequest = validRequests[0];
      const resetIn = tierConfig.window - (now - oldestRequest);

      return {
        allowed: false,
        reason: 'rate_limit_exceeded',
        limit: tierConfig.requests,
        remaining: 0,
        resetIn: Math.ceil(resetIn / 1000)
      };
    }

    // Add current request
    validRequests.push(now);
    this.requests.set(userId, validRequests);

    return {
      allowed: true,
      limit: tierConfig.requests,
      remaining: tierConfig.requests - validRequests.length,
      resetIn: Math.ceil(tierConfig.window / 1000)
    };
  }

  resetUser(userId) {
    this.requests.delete(userId);
  }

  getStats(userId) {
    const userRequests = this.requests.get(userId) || [];
    return {
      totalRequests: userRequests.length,
      oldestRequest: userRequests[0] || null,
      newestRequest: userRequests[userRequests.length - 1] || null
    };
  }
}

// Export for OpenClaw
module.exports = { RateLimiter };

Usage

const limiter = new skills.rateLimitPro.RateLimiter({
  tiers: {
    free: { requests: 10, window: 60000 },
    pro: { requests: 1000, window: 60000 }
  }
});

const result = limiter.checkLimit('user123', 'free');
if (result.allowed) {
  // Process request
} else {
  console.log(`Rate limit exceeded. Reset in ${result.resetIn}s`);
}

Configuration

{
  "tiers": {
    "free": { "requests": 10, "window": 60000 },
    "basic": { "requests": 100, "window": 60000 },
    "pro": { "requests": 1000, "window": 60000 }
  }
}

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

Coding

Codex Account Switcher

Query OpenAI Codex OAuth account quotas in OpenClaw, switch the preferred account by email/profile id, and optionally auto-switch when 5h quota drops below a...

Registry SourceRecently Updated
660Profile unavailable
General

Construction Cost Quoting Assistant

专业工程造价套定额工具,快速完成定额计价、成本测算,支持批量处理和智能推荐,适用于投标报价和工程结算。

Registry SourceRecently Updated
1950Profile unavailable
Coding

Skrape

Ethical web data extraction with robots exclusion protocol adherence, throttled scraping requests, and privacy-compliant handling ("Scrape responsibly!").

Registry SourceRecently Updated
2850Profile unavailable
General

API配额监控与手动切换

实时监控OpenClaw模型API配额,配额不足时询问用户确认后再切换模型,支持多模型优先级和手动指定切换。

Registry SourceRecently Updated
5860Profile unavailable