Type-Safe API Integration

Developer Toolsgithub-copilot-vs-cursorapi_nameapi_docs_url_or_descriptionendpoint_list

Both tools generate great TypeScript when given explicit type expectations. Copilot excels at generating repetitive typed functions from patterns. Cursor's multi-file Composer handles the separate types + client files cleanly.

Prompt
Generate a type-safe API client for {{api_name}}.

API documentation: {{api_docs_url_or_description}}
Endpoints I need:
{{endpoint_list}}

Requirements:
- Full TypeScript types for every request body and response shape
- Zod schemas that validate responses at runtime (don't trust the API)
- Generic fetch wrapper with:
  - Automatic retry on 429/503 with exponential backoff (max 3 retries)
  - Request timeout of {{timeout_ms}}ms
  - Auth header injection from {{auth_source}}
  - Response type narrowing (success vs error)
- Individual functions per endpoint (not a class with methods)
- Each function should accept typed params and return a typed Result<T, ApiError>

Error handling:
- Network errors → { type: 'network', message, retryable: true }
- Validation errors → { type: 'validation', message, raw: unknown }
- API errors → { type: 'api', status, message, code }

Generate the types file and client file separately. Export everything needed for consumers.

Variables to customize

{{api_name}}{{api_docs_url_or_description}}{{endpoint_list}}{{timeout_ms}}{{auth_source}}

Why this prompt works

Both tools generate great TypeScript when given explicit type expectations. Copilot excels at generating repetitive typed functions from patterns. Cursor's multi-file Composer handles the separate types + client files cleanly.

What you get when you save this prompt

Your workspace unlocks powerful tools to iterate and improve.

AI OPTIMIZE

AI Optimization

One-click improvement with structure analysis and pattern suggestions.

VERSION DIFF

Version History

Track every edit. Compare versions side-by-side with word-level diffs.

ORGANIZE
Development
Code Review
Testing
Marketing

Folders & Tags

Organize your library with nested folders, tags, and drag-and-drop.

MCP
$ npm i -g @promptingbox/mcp
Claude · Cursor · ChatGPT

Use Everywhere

Access prompts from Claude, Cursor, ChatGPT & more via MCP integration.

Your prompts, organized

Save, version, and access your best prompts across ChatGPT, Claude, Cursor, and more.