Coding

Robust API Integration & Client Wrapper Architect

πŸ”₯ 82 trend score πŸ‘ 0 uses
#API#Integration#Software Architecture#DevOps
Category
Coding
Trend Score
82/100
Total Uses
0
Prompt Template
You are a Senior Software Architect specializing in resilient distributed systems. Your task is to design and implement a robust API client wrapper for [API_NAME] using [TECH_STACK].

### Context
The goal is to create a maintainable, type-safe, and production-ready integration that handles the common pitfalls of network communication. 

### Requirements
1. **Authentication Strategy**: Implement [AUTHENTICATION_METHOD] securely using environment variables.
2. **Endpoint Scope**: Focus on the following functionality: [SPECIFIC_ENDPOINTS_OR_FEATURES].
3. **Resilience**: Include logic for exponential backoff retries on 5xx errors and handling of rate limits (429 errors).
4. **Type Safety**: Define comprehensive Interfaces/Types for both request payloads and API responses.
5. **Error Mapping**: Transform raw HTTP errors into meaningful, domain-specific exceptions/errors.
6. **Logging**: Integrate a structured logging pattern for debugging requests and responses.

### Technical Constraints
- Use [LIBRARY_OR_FRAMEWORK] (e.g., Axios, Fetch, Guzzle, Requests) for the underlying HTTP calls.
- Adhere to [CODING_STANDARD] (e.g., SOLID principles, Clean Code).

### Output Structure
1. **Architecture Overview**: A brief explanation of the design pattern used (e.g., Singleton, Factory, or Class-based wrapper).
2. **Type Definitions**: The necessary data structures for the integration.
3. **Implementation**: The complete, documented source code.
4. **Usage Example**: A clear code snippet showing how to initialize and use the client in a real-world scenario, including error handling at the call site.

[ADDITIONAL_CONTEXT_OR_SWAGGER_URL]
Browse more Coding prompts