api-integration

Implements async HTTP clients with retry logic, timeouts, rate limiting, and response validation.

Updated Sep 2, 2026
One-click install
npx skills add https://github.com/Dazlarus/karl-code --skill api-integration-dazlarus
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: api-integration
Source: https://github.com/Dazlarus/karl-code/tree/main/.agents/skills/api-integration
Command: npx skills add https://github.com/Dazlarus/karl-code --skill api-integration-dazlarus

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Integrating with external APIs often leads to fragile code: requests without timeouts, missing retry logic, unvalidated responses, and rate limit violations that cause production failures. This Skill provides proven patterns for building robust API integrations in Python. ## Core Features & Use Cases - Resilient HTTP Clients: Async HTTP clients with aiohttp, exponential backoff retries via tenacity, and mandatory timeouts on all requests. - Rate Limiting & Error Handling: Sliding-window rate limiters, typed exception hierarchies for 404/429/5xx responses, and graceful degradation. - Response Validation & Testing: Pydantic model validation for API responses and VCR.py cassette recording for deterministic API tests. - Use Case: When building a client for a third-party REST API, apply this Skill to encapsulate all calls in an async client class with authentication, retries, timeouts, and validated response models. ## Quick Start Review my API client code and add proper retry logic, timeouts, and Pydantic response validation.

Frequently Asked Questions about api-integration

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I add retry logic to Python API requests?▼

Use the tenacity library with the @retry decorator, configuring stop_after_attempt(3) and wait_exponential(multiplier=1, min=1, max=10). This retries failed requests with exponentially increasing delays between attempts.

How to handle rate limiting when calling external APIs?▼

Implement a sliding-window rate limiter that tracks request timestamps and sleeps when the limit is reached within the window. Also handle HTTP 429 responses explicitly by raising a dedicated RateLimitError.

Should I use aiohttp or requests for API calls in Python?▼

Use aiohttp for async applications where concurrent requests improve performance, and requests for simple synchronous scripts. This Skill recommends async clients with aiohttp for better throughput in I/O-bound API work.

How do I test code that calls external APIs?▼

Use VCR.py to record real API responses into cassette files and replay them during tests. This makes tests deterministic, fast, and independent of network availability or API keys.

Why validate API responses with Pydantic?▼

Pydantic validation catches schema mismatches at the boundary instead of deep in business logic. Defining response models like User with typed fields ensures malformed API data raises clear validation errors immediately.

When should I not apply these API integration patterns?▼

Skip these patterns for internal function calls and simple data transformations that involve no network I/O. Retry logic, timeouts, and rate limiting only add value when crossing process or network boundaries.