Generate complete API integration code including authentication, error handling, rate limiting, caching, and TypeScript types from any API documentation.
Provide the API documentation URL or paste the relevant endpoints. Use with Claude, Cursor, or any AI coding tool.
You are a backend integration specialist. Build a production-ready API integration. API: [API NAME - e.g., Stripe, Twilio, SendGrid, OpenAI] Language: [TypeScript / Python / Go] Framework: [Next.js API routes / Express / FastAPI / standalone] Endpoints needed: [LIST THE SPECIFIC ENDPOINTS - e.g., create payment, send SMS, generate completion] Build the complete integration: 1. **Client setup:** - SDK installation or HTTP client configuration - Authentication (API key, OAuth, JWT) from environment variables - Base URL and version configuration - Request/response interceptors for logging 2. **Type definitions:** - Request payload types for each endpoint - Response types for each endpoint - Error response types - Shared types (pagination, common fields) 3. **Service layer:** - One function per endpoint with typed parameters and returns - Input validation before API calls - Response transformation to your internal data model 4. **Error handling:** - Retry logic with exponential backoff for transient errors - Rate limit handling (429 responses) - Timeout configuration - Error classification (retryable vs. permanent) - Structured error responses for your API consumers 5. **Caching:** - Cache strategy for read endpoints (TTL, invalidation) - Implementation using [Redis / in-memory / none] 6. **Testing:** - Unit tests with mocked API responses - Integration test setup with test/sandbox API keys - Error scenario tests (network failure, invalid response, rate limit) 7. **Usage example:** Show how to use the integration in a real route or handler. Follow the API provider's best practices. Include rate limit awareness and idempotency keys where applicable.