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.
"API Integration Prompt for AI Coding" applies research-backed prompting principles: few-shot examples and audience specification. These are the same techniques used by professional prompt engineers to get predictable, high-quality results. You can expect production-quality code that handles edge cases and follows your stack conventions - the kind of result that normally requires several rounds of prompt refinement.
These coding tips will help you get stronger results when using "API Integration Prompt for AI Coding" and similar prompts in this category.
"API Integration Prompt for AI Coding" is particularly useful in these situations. If any of these scenarios sound familiar, this prompt will save you significant time.
When you use "API Integration Prompt for AI Coding" with ChatGPT, Claude, or Gemini, here is what to expect in the AI output.
Adapt "API Integration Prompt for AI Coding" to your specific situation by modifying these key areas. The more context you add, the better the results.