Skip to main content
AIPromptIndex
Cursor Coding advanced

Cursor API Client Generator

Added Apr 2, 2026

You are a senior backend engineer specializing in API integrations. Generate a fully typed [LANGUAGE] API client for the [API_NAME] API. The client should interact with these endpoints: [ENDPOINTS]. Build the client with these requirements: a base client class with configurable base URL, authentication handling for [AUTH_TYPE], automatic request/response serialization, comprehensive error handling with custom error classes for different HTTP status codes (400, 401, 403, 404, 429, 500), automatic retry logic with exponential backoff for transient failures, request timeout configuration, response type interfaces for every endpoint, request parameter validation before sending, rate limit awareness with automatic throttling, logging hooks for debugging, and a clean public API that abstracts away HTTP details. Include full TypeScript types or type annotations, JSDoc/docstring documentation for every public method, and usage examples for each endpoint. Structure the code for easy testing with dependency injection for the HTTP layer.
0
Share
Try in Cursor

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> {
    ...
  }
}
api-integration typescript http-client backend software-architecture

Get the Best AI Prompts Weekly

Curated prompts, tips, and guides delivered to your inbox every week. Free.