# API Rate Engineer

> Implements API rate limiting with nginx limit_req and limit_conn modules: shared memory zones, burst queues, delayed processing, and 429 responses. Use when working with nginx limit req, limit conn or when the user mentions nginx limit req, limit conn.

- Skill: `opknock/api-rate-engineer` (Agent Skill)
- Install (CLI): `npx get-skill add opknock/api-rate-engineer`
- Raw SKILL.md: https://api.skillmd.com/api/skills/opknock/api-rate-engineer/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Integrations & APIs
- License: MIT
- Author: OpKnock (https://skillmd.com/u/opknock)
- Updated: 2026-11-23
- Page: https://skillmd.com/skills/opknock/api-rate-engineer

---


Implements API rate limiting with nginx limit_req and limit_conn modules: shared memory zones, burst queues, delayed processing, and 429 responses.

## Agentic Workflow: Read -> Reason -> Act (api-rate-engineer)

You are **api-rate-engineer** (security) — a sub-agent that **Reads, Reasons, and Acts** via `allowed-tools`.

### 1. Read — security context for `api-rate-engineer`
- Domain: Implements API rate limiting with nginx limit_req and limit_conn modules: shared memory zones, burst queues, delayed processing, and 429 responses.
- **nginx-limit-req**: Configure request rate limiting zones in nginx — `nginx -t`
- **limit-conn**: Cap concurrent connections per client — `nginx -t -c /etc/nginx/nginx.conf`
- Check `knowledge` and `prerequisites: redis, node.js, python`

### 2. Reason — think for `api-rate-engineer`
- For `nginx-limit-req`: Configure request rate limiting zones in nginx — decide which checks to run
- For `limit-conn`: Cap concurrent connections per client — decide which checks to run
- Evaluate trust/policy: `kdesk trust` + `kdesk doctor` patterns for your inputs

### 3. Act — execute with `api-rate-engineer` tools
- Tools: `Glob`, `Grep`, `Read`, `Nginx`, `Bash` (see frontmatter `tools`/`allowed-tools`)
- Use `safe_path` for any write; record evidence (paths, checksums)
- Fingerprint: `api-rate-engineer:c6910a12`

# API Rate Engineer

Rate limiting with nginx.

## What This Skill Does
- Limits requests per second per client key
- Buffers bursts with queues or nodelay policy
- Limits concurrent connections per IP

## When to Use
- Protecting APIs behind nginx reverse proxy
- Throttling heavy endpoints without app changes
- Defending against single-IP abuse

## Real Commands

```bash
nginx -t
nginx -s reload
for i in $(seq 1 30); do curl -s -o /dev/null -w '%{http_code}\n' http://localhost/api/; done | sort | uniq -c
```

## Config Example

```nginx
limit_req_zone $binary_remote_addr zone=api:10m rate=10r/s;
server {
  location /api/ {
    limit_req zone=api burst=20 nodelay;
    limit_req_status 429;
    proxy_pass http://backend;
  }
}
```

## Testing
- Fire over-limit bursts and count 429 responses
- Verify Retry-After headers appear on 429s
- Confirm normal traffic below the limit is unaffected

## Best Practices
- Key zones on real client identity, not just IP
- Use burst+nodelay for interactive APIs
- Log limit violations to a dedicated access log

## Capabilities

### nginx-limit-req
Configure request rate limiting zones in nginx

**Parameters:**
- `zone-name` (string): Zone identifier with size like api:10m
- `rate` (string): Rate like 10r/s or 60r/m
- `burst` (integer): Queue size for exceeded requests

**Commands:**
- `nginx -t`
- `nginx -s reload`
- `curl -s -o /dev/null -w '%{http_code}\n' http://localhost/api/`
- `for i in $(seq 1 30); do curl -s -o /dev/null -w '%{http_code}\n' http://localhost/api/; done | sort | uniq -c`
- `curl -s -D- -o /dev/null http://localhost/api/ | grep -i retry-after`

**Examples:**
- limit_req_zone $binary_remote_addr zone=api:10m rate=10r/s defines the zone
- limit_req zone=api burst=20 nodelay applies it to a location
- nginx -t validates config before reload

### limit-conn
Cap concurrent connections per client

**Commands:**
- `nginx -t -c /etc/nginx/nginx.conf`
- `curl -s -o /dev/null -w '%{http_code}\n' http://localhost/api/health`
- `ab -n 500 -c 100 http://localhost/api/ 2>&1 | grep -i 'non-2xx'`

**Examples:**
- -cli --help
- -api --help

## References
- [nginx limit_req Module](https://nginx.org/en/docs/http/ngx_http_limit_req_module.html)
- [nginx limit_conn Module](https://nginx.org/en/docs/http/ngx_http_limit_conn_module.html)

