Cursor API Client Generator
Added Apr 2, 2026
About This Prompt
This prompt generates production-ready API client libraries that handle all the complexity of external API integration. Instead of making raw HTTP calls scattered throughout your codebase, you get a clean, typed, well-documented client with built-in error handling, retry logic, rate limiting, and authentication. The generated client follows best practices for API consumption including proper error classification, exponential backoff, and dependency injection for testability. This saves developers hours of boilerplate work and prevents common integration bugs like missing error handling, retry storms, and untyped responses.
Variables to Customize
[LANGUAGE]
Programming language for the client
Example: TypeScript
[API_NAME]
The API to build a client for
Example: Stripe Payments
[ENDPOINTS]
List of endpoints to support
Example: create payment intent, retrieve payment, list payments, create refund, retrieve customer
[AUTH_TYPE]
Authentication method used by the API
Example: Bearer token in Authorization header
Tips for Best Results
- Provide the actual API documentation URL for the most accurate endpoint typing
- Include rate limit specifications if known to generate accurate throttling logic
- Use the generated client as a foundation and add endpoint-specific validation as needed
Example Output
// stripe-client.ts
export interface PaymentIntent {
id: string;
amount: number;
currency: string;
status: 'requires_payment_method' | 'requires_confirmation' | 'succeeded' | 'canceled';
created: number;
}
export class StripeApiError extends Error {
constructor(public statusCode: number, public code: string, message: string) {
super(message);
this.name = 'StripeApiError';
}
}
export class StripeClient {
private readonly baseUrl = 'https://api.stripe.com/v1';
private readonly maxRetries = 3;
constructor(private readonly apiKey: string, private readonly httpClient: HttpClient = new FetchHttpClient()) {}
async createPaymentIntent(params: CreatePaymentIntentParams): Promise<PaymentIntent> {
...
}
}