Skip to content
Back to skills

External Api Calls And Rate Limits

ASecurity

Use when writing scripts or services that call external APIs, webhooks, or batch endpoints. Enforces timeouts, rate limiting, bounded parallelism, safe retries, and session reuse.

  • 4 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added December 1, 2026
ai-agentsgoapi

Works with

  • cli
  • api

Security analysis

A100/100

Scanned December 1, 2026

npx -y skills add Ganesh-Dark/ai-coding-agent-skills --skill external-api-calls-and-rate-limits --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of External Api Calls And Rate Limits?

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

Security grade badge for External Api Calls And Rate Limits
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/ganesh-dark-external-api-calls-and-rate-limits/badge)](https://www.skillsdirectory.com/skills/ganesh-dark-external-api-calls-and-rate-limits)

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: external-api-calls-and-rate-limits
description: Use when writing scripts or services that call external APIs, webhooks, or batch endpoints. Enforces timeouts, rate limiting, bounded parallelism, safe retries, and session reuse.
---

# External API Calls and Rate Limits

Scripts that call external APIs often hang without timeouts, fire unbounded parallel requests that trigger `429` bans, retry permanent errors forever, or lose progress halfway through a large batch.

## Rules

- Always set explicit timeouts on every HTTP request (`requests`, `httpx`, `urllib`, or `aiohttp`). Never let a hung socket freeze a script forever.
- Bound parallelism strictly. Use `ThreadPoolExecutor(max_workers=5)` or `asyncio.Semaphore(5)` instead of firing unbounded `asyncio.gather(*...)` or hundreds of threads at once.
- Coordinate rate limits across parallel workers. Respect `429` and `Retry-After` headers, and share a rate limiter or token bucket so workers back off together instead of hammering the API.
- Retry only transient failures (`429`, `502`, `503`, `504`, and network timeouts) using exponential backoff with jitter and a strict max retry cap. Never retry `400`, `401`, `403`, or `404`.
- Reuse HTTP connections with a shared `requests.Session()` or `httpx.Client()`, checkpoint large batch runs so they can resume, and never log API keys or auth headers.

## Example

Bad:
Running `asyncio.gather(*[fetch(u) for u in urls])` or `ThreadPoolExecutor(max_workers=200)` over 2,000 URLs with no `timeout`, no concurrency limit, and a retry loop that retries `401 Unauthorized` forever.

Good:
Running `ThreadPoolExecutor(max_workers=5)` (or `asyncio.Semaphore(5)`) with a shared `requests.Session()`, a 10-second `timeout`, a shared rate limiter honoring `Retry-After` on `429`/`5xx`, and saving completed IDs to resume on failure.

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.

View all in ai-agents →

Comments

Loading comments…

Newsletter

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