Skip to content

Instantly share code, notes, and snippets.

@mrichman
Created January 20, 2026 22:05
Show Gist options
  • Select an option

  • Save mrichman/c95218612fa084736cf3f9d3d3e18125 to your computer and use it in GitHub Desktop.

Select an option

Save mrichman/c95218612fa084736cf3f9d3d3e18125 to your computer and use it in GitHub Desktop.
API Gateway — When to choose which?

API Gateway: When to Choose Which

Decision Flow

Need real-time/persistent connections?
    → WebSocket API

Need transformations, API keys, usage plans?
    → REST API

Simple proxy, cost/performance optimized?
    → HTTP API

HTTP API

Best For:

  • Low latency requirements
  • Cost optimization (70% cheaper)
  • Simple proxy to Lambda/HTTP
  • JWT/OAuth2 authorization
  • Modern REST APIs

Not Ideal For:

  • Request/response transformation
  • API keys needed
  • Usage plans/throttling
  • Complex request validation

Use When:

Building new APIs, microservices, serverless backends


REST API

Best For:

  • Request/response transformation
  • API keys & usage plans
  • Fine-grained throttling
  • Mock integrations
  • SDK generation
  • Request validation models
  • Legacy system integration

Not Ideal For:

  • Cost-sensitive projects
  • Ultra-low latency needs
  • Simple proxy scenarios

Use When:

Complex enterprise APIs, partner integrations, detailed control needed


WebSocket API

Best For:

  • Bi-directional communication
  • Real-time data streaming
  • Chat applications
  • Live dashboards
  • Gaming backends
  • IoT device communication

Not Ideal For:

  • Request-response patterns
  • Traditional REST operations
  • Batch processing

Use When:

Real-time, persistent connections required


Feature Comparison

Feature HTTP API REST API WebSocket API
Pricing Lowest Moderate Pay per message
Latency Fastest Good Real-time
Authorization JWT, OAuth2, Lambda, IAM Lambda, Cognito, IAM, API Keys Lambda, IAM
Transformations Limited Full VTL Lambda only
Caching No Yes No
Throttling Basic Advanced Per route

Quick Reference

  • HTTP API: Default for new projects
  • REST API: When you need control
  • WebSocket: Real-time only
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment