Skip to content
Back to skills

1 Rate Limiting

ASecurity

Sub-skill of bsee-sodir-extraction: 1. Rate Limiting (+2).

  • 17 stars
  • 0 votes
  • 0 copies
  • 5 views
  • Added September 9, 2026
developmentpythongoapi

Works with

  • api

Security analysis

A100/100

Scanned September 9, 2026

npx -y skills add vamseeachanta/workspace-hub --skill 1-rate-limiting --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of 1 Rate Limiting?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for 1 Rate Limiting
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/vamseeachanta-1-rate-limiting-4677c236/badge)](https://www.skillsdirectory.com/skills/vamseeachanta-1-rate-limiting-4677c236)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: bsee-sodir-extraction-1-rate-limiting
description: 'Sub-skill of bsee-sodir-extraction: 1. Rate Limiting (+2).'
version: 1.0.0
category: data-analysis
type: reference
scripts_exempt: true
---

# 1. Rate Limiting (+2)

## 1. Rate Limiting


```python
import time
from functools import wraps

def rate_limit(calls_per_minute: int = 30):
    """Decorator to rate limit API calls."""
    min_interval = 60.0 / calls_per_minute
    last_call = [0.0]

    def decorator(func):
        @wraps(func)
        def wrapper(*args, **kwargs):
            elapsed = time.time() - last_call[0]
            if elapsed < min_interval:
                time.sleep(min_interval - elapsed)
            last_call[0] = time.time()
            return func(*args, **kwargs)
        return wrapper
    return decorator

@rate_limit(calls_per_minute=30)
def fetch_with_rate_limit(url: str) -> requests.Response:
    return requests.get(url)
```


## 2. Caching


```python
from functools import lru_cache
from datetime import datetime, timedelta

@lru_cache(maxsize=100)
def cached_fetch(url: str, cache_hours: int = 24) -> pd.DataFrame:
    """Fetch with caching."""
    cache_file = Path(f".cache/{hash(url)}.parquet")

    if cache_file.exists():
        mtime = datetime.fromtimestamp(cache_file.stat().st_mtime)
        if datetime.now() - mtime < timedelta(hours=cache_hours):
            return pd.read_parquet(cache_file)

    # Fetch fresh data
    response = requests.get(url)
    df = pd.DataFrame(response.json())

    cache_file.parent.mkdir(exist_ok=True)
    df.to_parquet(cache_file)

    return df
```


## 3. Error Handling


```python
import logging
from tenacity import retry, stop_after_attempt, wait_exponential

logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)

@retry(stop=stop_after_attempt(3), wait=wait_exponential(multiplier=1, min=4, max=10))
def robust_fetch(url: str) -> requests.Response:
    """Fetch with automatic retry on failure."""
    try:
        response = requests.get(url, timeout=60)
        response.raise_for_status()
        return response
    except requests.exceptions.RequestException as e:
        logger.error(f"Fetch failed for {url}: {e}")
        raise
```

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.