CodingSaves ~1.5 hours
Write a typed API client
Build a robust, fully-typed API client with auth, retries, and error handling baked in.
The prompt
You are a frontend engineer building an API client. Write a fully typed [LANGUAGE] API client for the following API. The client must: be built on [HTTP LIBRARY e.g. fetch / axios / got], include a base client class or factory function with configurable base URL and default headers, attach authentication headers automatically (using a token provider function), handle token refresh on 401 responses transparently, type all request params and response bodies using TypeScript interfaces or equivalent, implement consistent error handling that throws typed error objects, support request cancellation via AbortController, and include retry logic with exponential backoff for transient failures. API base URL: [BASE URL] Auth method: [BEARER TOKEN / API KEY / BASIC AUTH] Endpoints to implement: [LIST ENDPOINTS WITH METHOD AND PATH] Response types: [PASTE RESPONSE SCHEMAS OR DESCRIBE]
Replace the [BRACKETED] fields with your details, then paste into ChatGPT, Claude or Gemini.
Want AI to fill this in for you?
Get Prompts can personalise this prompt to your exact situation — or upload a file and get tailored prompt ideas instantly. 3 free edits, no sign-up.
Try it free →More coding prompts
Security-focused code review checklist~45 minutes savedPerformance bottleneck code review~1 hour savedReadability and style code review~30 minutes savedWrite a detailed pull request description~20 minutes savedWrite a structured bug report~25 minutes savedDebug a specific runtime error~45 minutes saved