What problem does it solve?
This Skill automates the complex and error-prone aspects of integrating external APIs and databases, saving you significant development time and reducing the risk of integration failures. It handles authentication, error handling, and data validation, letting you focus on core logic.
Core Features & Use Cases
- Robust API Calls: Patterns for REST and GraphQL APIs with built-in retry logic and comprehensive error handling (4xx, 5xx, timeouts).
- Secure Authentication: Supports Bearer Token, Basic Auth, and OAuth 2.0, ensuring secure connections to external services.
- Response Validation: Integrates JSON schema validation (e.g., with Pydantic) to ensure data integrity from API responses.
- Use Case: Integrate a payment gateway like Stripe, fetch data from a third-party service like Twilio, or query a PostgreSQL database, all with automated error recovery and data validation.
Quick Start
Example: Get user info from GitHub API
import requests
from tenacity import retry, stop_after_attempt, wait_exponential
@retry(stop=stop_after_attempt(3), wait=wait_exponential(multiplier=1, min=1, max=10))
def call_api(endpoint, method="GET", headers=None, data=None):
response = requests.request(method=method, url=endpoint, headers=headers, json=data, timeout=30)
response.raise_for_status()
return response.json()
response = call_api('https://api.github.com/users/github')
print(f"GitHub created: {response['created_at']}")