wowprompt

Third-party API client with retries, timeouts and rate limits

Writes a small, reusable client for calling an external REST API, with timeouts, retries with backoff, rate-limit handling and typed responses. Use it when integrating a payment, shipping, messaging or data API and you want the integration to survive slow or failing responses.

An API client module with configuration from environment variables, methods for the listed endpoints, retry and rate-limit logic, error types, and a usage example with tests to write
The output this prompt produced, unedited.

The prompt

Fill in these first

  • Language and HTTP library: [e.g. TypeScript with fetch, Python with httpx, PHP with Guzzle]
  • API base URL and authentication method: [e.g. bearer token in a header, API key in a header]
  • Endpoints needed: [method, path, request fields and response fields for each]
  • Rate limit documented by the provider: [e.g. 10 requests per second, with a Retry-After header on 429]
  • Which calls are safe to retry: [e.g. GET requests, and POST requests that accept an idempotency key]

Task

Write a client module for this API that a team can reuse across the codebase.

Output format

  1. The client module in one code block, with:
  • configuration read from environment variables, never hard-coded
  • a timeout on every request
  • retries with exponential backoff and jitter, for network errors, 429 and 5xx only
  • respect for the Retry-After header
  • typed request and response objects
  • clear error types for authentication, validation, rate limit and server errors
  1. A usage example.
  2. A list of tests to write, including timeout, 429 with Retry-After, and a non-retryable 400.

Rules

  • Never retry a request that is not safe to repeat unless it carries an idempotency key.
  • Cap retries, for example at three attempts, and cap the total wait time.
  • Never log the API key or the full authorisation header.
  • Use only endpoints and fields from the inputs; do not guess undocumented fields.

Example

Retry delays with jitter: about 0.5 s, 1 s, 2 s, each plus a random 0 to 250 ms.

api clientrest api integrationretry with backoffrate limitinghttp timeoutthird party api

How to run this

Copy the prompt and paste it into Gemini, then set the aspect ratio to 3:4. No reference photo is needed for this one.

The prompt is written in Markdown with each part under its own heading, which is what the copy action hands over. Change one section at a time, keeping the rest intact, so you can tell which change did the work.

Related prompts

All productivity