DEV Community

Preecha
Preecha

Posted on

AWS API Gateway Cost: Pricing & Optimization Guide

When designing and deploying APIs in the cloud, understanding AWS API Gateway cost is essential for controlling spend, scaling safely, and maintaining reliable services. This guide breaks down the main pricing models, shows practical cost calculations, and provides implementation-focused steps to reduce API Gateway expenses.

Try Apidog today

What Is AWS API Gateway Cost?

AWS API Gateway cost is the total amount you pay to use Amazon API Gateway, including request processing, data transfer, caching, and optional features. Your bill depends primarily on:

  • The API type: HTTP, REST, or WebSocket.
  • Request or message volume.
  • Outbound data transfer.
  • REST API cache capacity.
  • Optional services such as custom domains and AWS WAF.
  • Backend services such as AWS Lambda, DynamoDB, or other AWS integrations.

Estimate these costs before deploying so you can:

  • Forecast monthly or annual cloud spend.
  • Prevent billing surprises as traffic grows.
  • Choose an API type that matches the workload and budget.

Understand AWS API Gateway Pricing Models

API Types and Cost Structures

API Gateway provides three primary API types:

API Type Cost per Million Requests (First Tier) Cost per Million Requests (Next Tier) Best For
HTTP APIs $1.00 (first 300M) $0.90 (over 300M) Simple, low-latency, serverless APIs
REST APIs $3.50 (first 333M) Tiered pricing APIs requiring caching, API keys, request validation, or throttling
WebSocket APIs $1.00 (first 1B messages) $0.80 (over 1B messages) Real-time, bidirectional communication

HTTP APIs are up to 71% cheaper than REST APIs for high-volume workloads. Start with HTTP APIs unless your application specifically requires REST API features such as usage plans, API keys, or API Gateway caching.

AWS API Gateway Free Tier

For new customers, AWS provides a Free Tier that includes:

  • 1 million API calls per month for HTTP APIs, REST APIs, and WebSocket APIs for up to 12 months.
  • 750,000 connection minutes per month for WebSocket APIs.

Use the Free Tier for prototypes and early testing, but configure budget alerts before traffic exceeds those limits.

Data Transfer Fees

Request charges are not the only API Gateway expense. Public APIs can also incur outbound internet data-transfer charges.

  • Public API outbound transfer: typically $0.09 per GB in many AWS regions.
  • Private APIs: traffic accessible only within your VPC does not incur outbound data-transfer fees through API Gateway.

Always verify regional pricing before finalizing an estimate.

Optional Features That Affect Cost

Feature Cost Impact
REST API caching Hourly cache charge, starting at $0.02/hour for 0.5 GB
Custom domain names Small monthly charge
AWS WAF Separate AWS WAF charges
Lambda, DynamoDB, and other integrations Separate service charges

Break Down Your AWS API Gateway Cost

Use this formula as a starting point:

Total monthly API Gateway cost =
  request or message charges
  + outbound data transfer
  + cache charges
  + custom domain and optional feature charges
  + related backend service costs
Enter fullscreen mode Exit fullscreen mode

1. Calculate Request Charges

Multiply monthly requests by the per-million-request rate for the API type.

HTTP API example

10 million requests × $1.00 per million = $10/month
Enter fullscreen mode Exit fullscreen mode

REST API example

10 million requests × $3.50 per million = $35/month
Enter fullscreen mode Exit fullscreen mode

WebSocket API example

50 million messages × $1.00 per million = $50/month
Enter fullscreen mode Exit fullscreen mode

2. Calculate Data Transfer

Estimate the total response data sent to the public internet.

2 GB outbound data × $0.09 per GB = $0.18/month
Enter fullscreen mode Exit fullscreen mode

Add this amount to request charges.

3. Calculate REST API Cache Charges

REST API caching is billed hourly. For example, a 1 GB cache running for an entire month:

1 GB cache × $0.04/hour × 730 hours = $29.20/month
Enter fullscreen mode Exit fullscreen mode

Before enabling a cache, confirm that its backend savings justify its fixed hourly cost.

4. Include Custom Domains and Certificates

  • Custom domain name: typically $1.00/month, depending on region.
  • SSL certificate: free when using AWS Certificate Manager (ACM).

5. Account for Backend Costs

API Gateway may invoke services that have their own pricing, including:

  • AWS Lambda
  • Amazon DynamoDB
  • Amazon RDS
  • Amazon SQS
  • Other AWS services or external integrations

Track API Gateway and backend costs together. A low API Gateway bill can still trigger high Lambda invocation or database costs.

Real-World AWS API Gateway Cost Examples

Example 1: Small Startup Prototype

Scenario: A mobile application uses an HTTP API with 1 million requests per month. Each response is 100 KB.

HTTP API requests:
1M requests = $0 under the Free Tier

Outbound data transfer:
100 KB × 1M requests = 100 GB/month
100 GB × $0.09 = $9.00/month

Total estimated cost:
$9.00/month
Enter fullscreen mode Exit fullscreen mode

The request volume fits within the Free Tier, but response payload size still drives data-transfer cost.

Example 2: Growing SaaS Product

Scenario: A SaaS product processes 50 million REST API requests per month, uses a 2 GB cache, and transfers 500 GB of data.

REST API requests:
50M × $3.50 per million = $175.00

Cache:
2 GB × $0.04/hour × 730 hours = $58.40

Outbound data transfer:
500 GB × $0.09 = $45.00

Total estimated cost:
$278.40/month
Enter fullscreen mode Exit fullscreen mode

In this example, request processing is the largest component, followed by caching.

Example 3: Real-Time Chat Application

Scenario: A WebSocket API handles 200 million messages per month and 1 million connection minutes.

WebSocket messages:
200M × $1.00 per million = $200.00

Connection minutes:
1M connection minutes = $0 within the Free Tier

Total estimated cost:
$200.00/month
Enter fullscreen mode Exit fullscreen mode

For WebSocket workloads, monitor both message volume and connection duration.

How to Reduce AWS API Gateway Cost

1. Choose the Right API Type

Use the least expensive API type that satisfies your requirements.

  • Choose HTTP APIs for stateless APIs, simple Lambda integrations, and standard request-response workloads.
  • Use REST APIs only when you need features such as API keys, usage plans, request validation, throttling, or API Gateway caching.
  • Use WebSocket APIs for persistent, bidirectional communication such as chat, notifications, or live dashboards.

2. Reduce Response Payload Size

Outbound data transfer can become significant when APIs return large responses.

Practical options include:

  • Return only fields required by the client.
  • Paginate large collections.
  • Compress responses where appropriate.
  • Avoid embedding large binary payloads in API responses.
  • Use object storage or a CDN for large files instead of serving them directly through API Gateway.

For example, paginate a collection endpoint instead of returning all records:

GET /users?limit=50&cursor=next-page-token
Enter fullscreen mode Exit fullscreen mode

3. Cache Only High-Value REST Endpoints

Caching can reduce backend calls, but it creates a fixed hourly cost.

Use caching for endpoints that are:

  • Read-heavy.
  • Frequently requested.
  • Safe to serve with a short-lived response.
  • Expensive for the backend to compute.

Monitor cache hit rates. If the cache rarely serves hits, remove or resize it.

4. Set Cost and Usage Alerts

Configure alerts before an unexpected traffic increase becomes a billing issue.

Use:

  • AWS Cost Explorer to review historical spend.
  • AWS Budgets to alert on monthly thresholds.
  • Amazon CloudWatch to monitor request counts, latency, errors, and throttling.

A practical workflow:

  1. Set a monthly API budget.
  2. Add alerts at 50%, 80%, and 100% of the budget.
  3. Review request volume by API stage and route.
  4. Investigate sudden increases in 4xx, 5xx, or total request counts.

5. Use Private APIs for Internal Traffic

If consumers are inside your VPC, use private APIs where appropriate. This can avoid public outbound data-transfer charges through API Gateway.

6. Optimize Backend Integrations

API Gateway pricing is only part of total API cost. Reduce downstream work by:

  • Avoiding unnecessary Lambda invocations.
  • Batching database reads where possible.
  • Returning cached data for repeat requests.
  • Validating requests early to prevent invalid calls from reaching expensive backend services.

7. Design and Test APIs Before Production

Tools like Apidog can help streamline API design, documentation, mocking, and testing. Use them to validate endpoint behavior before production traffic generates AWS charges.

A practical pre-deployment workflow:

  1. Import an OpenAPI or Swagger definition.
  2. Define request and response examples.
  3. Mock endpoint behavior for frontend and integration testing.
  4. Test expected request patterns.
  5. Remove unused endpoints and oversized responses before deployment.

Practical Example: Calculate Your Monthly Cost

Estimate costs for each API independently, then sum them.

Step 1: Estimate Monthly Request Volume

List expected traffic by API type:

HTTP API: 25 million requests/month
REST API: 0 requests/month
WebSocket API: 0 messages/month
Enter fullscreen mode Exit fullscreen mode

Step 2: Apply Request Pricing

25 million HTTP API requests × $1.00 per million = $25.00
Enter fullscreen mode Exit fullscreen mode

Step 3: Estimate Outbound Data Transfer

100 GB outbound data × $0.09 per GB = $9.00
Enter fullscreen mode Exit fullscreen mode

Step 4: Add Cache Costs

HTTP APIs do not support API Gateway caching, so this cost is zero.

Cache cost = $0.00
Enter fullscreen mode Exit fullscreen mode

Step 5: Add Optional Features

Custom domain = $1.00
Enter fullscreen mode Exit fullscreen mode

Step 6: Calculate the Total

Request charges:      $25.00
Data transfer:         $9.00
Cache:                 $0.00
Custom domain:         $1.00
--------------------------------
Estimated monthly cost: $35.00
Enter fullscreen mode Exit fullscreen mode

AWS API Gateway Cost in Multi-Region Deployments

For multi-region APIs, calculate costs separately for each AWS region.

Keep these points in mind:

  • API Gateway request charges apply per region.
  • Traffic patterns can vary by region.
  • Cross-region data transfer has additional costs not included in API Gateway request pricing.
  • Each region may require separate cache, domain, and backend capacity planning.

Create a cost worksheet per region instead of applying one global estimate.

How Apidog Helps Manage AWS API Gateway Cost

Apidog can support cost-aware API development by helping teams:

  • Design lean APIs: Define, mock, and test APIs before deployment to avoid unnecessary endpoints and calls.
  • Maintain documentation: Generate and update API documentation to reduce incorrect integrations and accidental overuse.
  • Import and test API specifications: Bring in Swagger or OpenAPI definitions and simulate API behavior before production traffic reaches AWS.

Use this workflow to identify inefficient endpoints early:

Define API contract
→ mock responses
→ test request flows
→ measure expected payload sizes
→ remove unnecessary calls
→ deploy to API Gateway
Enter fullscreen mode Exit fullscreen mode

Conclusion: Mastering AWS API Gateway Cost

AWS API Gateway cost is driven by request volume, data transfer, caching, optional features, and connected backend services. Start with the appropriate API type, measure traffic and payload sizes, and continuously monitor usage as your application grows.

Key takeaways:

  • Use HTTP APIs for simple, stateless workloads whenever possible.
  • Use REST APIs only when their advanced features are required.
  • Track data transfer as carefully as request volume.
  • Enable caching only when cache hit rates justify the hourly charge.
  • Set AWS Budgets and CloudWatch alerts before deploying at scale.
  • Test API contracts, payloads, and request patterns before production to avoid unnecessary API calls.

Top comments (0)