---
title: "What Is an API Gateway? API Gateway Software and Use Cases - API7.ai"
description: "Learn how gateway software routes API traffic and applies authentication, rate limits, transformations, load balancing, and observability policies."
url: "https://api7.ai/learning-center/api-gateway-guide/what-is-an-api-gateway"
---

[Skip to article](#column-content)

Column contentsAPI Gateway Guide

[API Gateway Guide](https://api7.ai/learning-center/api-gateway-guide)

Search this column

01 Gateway Fundamentals

[View this topic · 10](https://api7.ai/learning-center/api-gateway-guide?topic=fundamentals)[1. What Is an API Gateway? API Gateway Software and Use Cases](https://api7.ai/learning-center/api-gateway-guide/what-is-an-api-gateway)[2. Why Do Modern Architectures Need an API Gateway?](https://api7.ai/learning-center/api-gateway-guide/why-do-modern-architectures-need-api-gateway)[3. Reverse Proxy vs Load Balancer vs API Gateway](https://api7.ai/learning-center/api-gateway-guide/api-gateway-vs-reverse-proxy-vs-load-balancer)[4. API Gateway and Microservices: Decoupling and Traffic Management](https://api7.ai/learning-center/api-gateway-guide/api-gateway-and-microservices)[5. Understanding Core API Gateway Features](https://api7.ai/learning-center/api-gateway-guide/core-api-gateway-features)[6. Open Source vs. Commercial API Gateways: How to Choose the Right One?](https://api7.ai/learning-center/api-gateway-guide/open-source-vs-commercial-api-gateway)[7. API Gateway vs Service Mesh: How to Choose?](https://api7.ai/learning-center/api-gateway-guide/api-gateway-vs-service-mesh)[8. Envoy vs NGINX, Java, and Go for API Gateways](https://api7.ai/learning-center/api-gateway-guide/nginx-vs-envoy-vs-java-vs-go)[9. Core Concepts of API Gateway: Service, Route, Upstream, Plugin, and Consumer](https://api7.ai/learning-center/api-gateway-guide/core-concepts-of-api-gateway)[10. API Gateway Comparison: Apache APISIX vs. Kong vs. Traefik vs. KrakenD vs. Tyk](https://api7.ai/learning-center/api-gateway-guide/api-gateway-comparison-apisix-kong-traefik-krakend-tyk)

02 Gateway Architecture and Design

[View this topic · 10](https://api7.ai/learning-center/api-gateway-guide?topic=architecture)[11. Deep Dive into API Gateway Architecture: Core Components and Design Principles](https://api7.ai/learning-center/api-gateway-guide/api-gateway-architecture)[12. Choosing the Right API Gateway for Your Architecture](https://api7.ai/learning-center/api-gateway-guide/api-gateway-monolithic-vs-microservices)[13. How to Architect an API Gateway for High Availability (HA)?](https://api7.ai/learning-center/api-gateway-guide/api-gateway-high-availability)[14. API Gateway Plugin Architecture: How to Extend and Customize Your API Gateway](https://api7.ai/learning-center/api-gateway-guide/api-gateway-plugin-system)[15. How Event-Driven Architecture (EDA) Works with API Gateway?](https://api7.ai/learning-center/api-gateway-guide/api-gateway-event-driven-architecture)[16. API Gateway Request Lifecycle Explained](https://api7.ai/learning-center/api-gateway-guide/api-gateway-request-lifecycle-explained)[17. Cloud-Native API Gateway on Kubernetes](https://api7.ai/learning-center/api-gateway-guide/cloud-native-api-gateway-kubernetes)[18. API Gateway Control Plane vs. Data Plane](https://api7.ai/learning-center/api-gateway-guide/api-gateway-control-plane-vs-data-plane)[19. How API Gateways Work with GitOps: Automating API Management](https://api7.ai/learning-center/api-gateway-guide/api-gateway-gitops-integration)[20. How to Perform A/B Testing and Canary Releases with an API Gateway](https://api7.ai/learning-center/api-gateway-guide/ab-testing-canary-release-api-gateway)

03 Gateway Setup and Traffic Handling

[View this topic · 10](https://api7.ai/learning-center/api-gateway-guide?topic=traffic-protocols)[21. How to Deploy an API Gateway on Kubernetes: Step-by-Step Guide for Engineers](https://api7.ai/learning-center/api-gateway-guide/deploy-api-gateway-on-kubernetes)[22. Hands-on Setup with Apache APISIX API Gateway](https://api7.ai/learning-center/api-gateway-guide/api-gateway-getting-started-guide)[23. API Gateway Auth: OAuth 2.0, JWT & OIDC with APISIX](https://api7.ai/learning-center/api-gateway-guide/api-gateway-authentication-apache-apisix-oauth-jwt-oidc)[24. Mastering Traffic Control: Efficiently Managing API Requests with Gateways](https://api7.ai/learning-center/api-gateway-guide/api-gateway-traffic-control-strategies)[25. Building Reliable API Gateways with Logging and Monitoring](https://api7.ai/learning-center/api-gateway-guide/api-gateway-logging-monitoring-best-practices)[26. Dynamic Routing in API Gateways: Best Practices for Flexible Traffic Management](https://api7.ai/learning-center/api-gateway-guide/api-gateway-dynamic-routing-management)[27. How API Gateways Support WebSocket](https://api7.ai/learning-center/api-gateway-guide/how-api-gateways-support-websocket)[28. API Gateway for GraphQL: Security, Cost, and Caching](https://api7.ai/learning-center/api-gateway-guide/api-gateway-handle-graphql)[29. How API Gateways Handle HTTP/3 QUIC Requests](https://api7.ai/learning-center/api-gateway-guide/api-gateway-http3-quic)[30. How API Gateways Handle MQTT Requests](https://api7.ai/learning-center/api-gateway-guide/api-gateway-mqtt)

04 Gateway Integrations, AI, and MCP

[View this topic · 10](https://api7.ai/learning-center/api-gateway-guide?topic=ai-mcp)[31. How API Gateways Handle gRPC Requests](https://api7.ai/learning-center/api-gateway-guide/api-gateway-grpc-support)[32. How API Gateways Implement Custom Plugins](https://api7.ai/learning-center/api-gateway-guide/api-gateway-custom-plugins)[33. How API Gateways Integrate with Kafka](https://api7.ai/learning-center/api-gateway-guide/api-gateway-kafka-integration)[34. How to Implement API Aggregation in API Gateways](https://api7.ai/learning-center/api-gateway-guide/api-gateway-api-aggregation)[35. How API Gateways Enable Serverless Architecture](https://api7.ai/learning-center/api-gateway-guide/api-gateway-serverless-architecture)[36. How API Gateways Proxy LLM Requests](https://api7.ai/learning-center/api-gateway-guide/api-gateway-proxy-llm-requests)[37. How API Gateways Enhance MCP Servers](https://api7.ai/learning-center/api-gateway-guide/api-gateway-enhance-mcp-server)[38. MCP Gateway vs MCP Proxy vs AI Gateway vs API Gateway](https://api7.ai/learning-center/api-gateway-guide/ai-gateway-vs-mcp-gateway-vs-api-gateway)[39. What Is an AI Gateway? Architecture and Benefits](https://api7.ai/learning-center/api-gateway-guide/what-is-an-ai-gateway)[40. What Is an MCP Gateway? Architecture, Use Cases & How It Works (2026 Guide)](https://api7.ai/learning-center/api-gateway-guide/what-is-mcp-gateway)

05 Gateway Performance

[View this topic · 10](https://api7.ai/learning-center/api-gateway-guide?topic=performance)[41. How API Gateway Reduces Latency: Performance Optimization Strategies](https://api7.ai/learning-center/api-gateway-guide/how-api-gateway-reduces-latency)[42. API Gateway Caching Strategy: Comprehensive Analysis and Implementation Guide](https://api7.ai/learning-center/api-gateway-guide/api-gateway-caching-strategy-analysis)[43. How to Optimize API Gateway Load Balancing: Advanced Strategies and Best Practices](https://api7.ai/learning-center/api-gateway-guide/how-to-optimize-api-gateway-load-balancing)[44. How API Gateway Efficiently Handles Large-Scale Traffic: Architecture and Strategies](https://api7.ai/learning-center/api-gateway-guide/how-api-gateway-handles-large-scale-traffic)[45. How to Improve API Gateway QoS: Traffic Classes, Capacity Protection, and SLOs](https://api7.ai/learning-center/api-gateway-guide/api-gateway-quality-of-service)[46. API Gateway Log Storage: Pipelines, Retention, Security, and Cost](https://api7.ai/learning-center/api-gateway-guide/api-gateway-log-storage)[47. API Gateway Timeouts and Retries: Safe Policies and APISIX Configuration](https://api7.ai/learning-center/api-gateway-guide/api-gateway-timeouts-retries)[48. API Gateway Concurrency Control: Capacity Budgets, Backpressure, and Load Shedding](https://api7.ai/learning-center/api-gateway-guide/api-gateway-concurrency-control)[49. Asynchronous API Gateway Patterns: Queues, Callbacks, and Performance Boundaries](https://api7.ai/learning-center/api-gateway-guide/asynchronous-api-gateway-patterns)[50. API Gateway TLS Performance: Handshakes, Session Reuse, and Measurement](https://api7.ai/learning-center/api-gateway-guide/api-gateway-tls-performance)

06 Gateway Security

[View this topic · 10](https://api7.ai/learning-center/api-gateway-guide?topic=security)[51. DDoS Defense at the API Gateway: Layered Controls and Failure Planning](https://api7.ai/learning-center/api-gateway-guide/api-gateway-ddos-defense)[52. Distributed API Gateway Rate Limiting: Local vs Redis Counters and Accuracy Trade-offs](https://api7.ai/learning-center/api-gateway-guide/distributed-api-gateway-rate-limiting)[53. API Gateway IP Allowlist and Denylist Management: Trust, Proxies, and Operations](https://api7.ai/learning-center/api-gateway-guide/api-gateway-ip-allowlist-denylist-management)[54. API Gateway Security Scanning: What to Test and How to Operationalize Findings](https://api7.ai/learning-center/api-gateway-guide/api-gateway-security-scanning)[55. SQL Injection and XSS at the API Gateway: Detection Limits and Defense in Depth](https://api7.ai/learning-center/api-gateway-guide/sql-injection-xss-api-gateway)[56. API Access Log Auditing: Evidence, Integrity, Retention, and Review](https://api7.ai/learning-center/api-gateway-guide/api-access-log-auditing)[57. Preventing API Scraping and Abuse: Identity, Behavioral Signals, and Rate Controls](https://api7.ai/learning-center/api-gateway-guide/prevent-api-scraping-abuse)[58. API Gateway mTLS: Client Identity, Certificate Rotation, and APISIX Configuration](https://api7.ai/learning-center/api-gateway-guide/api-gateway-mtls)[59. Fine-Grained API Gateway Authorization: RBAC, ABAC, and External Policy Decisions](https://api7.ai/learning-center/api-gateway-guide/fine-grained-api-gateway-authorization)[60. API Gateway and WAF Reference Architecture: Ownership, Header Trust, and Failure Modes](https://api7.ai/learning-center/api-gateway-guide/api-gateway-waf-reference-architecture)

07 Gateway Ecosystem and Comparisons

[View this topic · 10](https://api7.ai/learning-center/api-gateway-guide?topic=ecosystem)[61. Apache APISIX vs Kong: Migration, Operations, and Team Fit](https://api7.ai/learning-center/api-gateway-guide/apache-apisix-vs-kong)[62. Traefik vs Kong vs APISIX: A Reproducible API Gateway Benchmark Method](https://api7.ai/learning-center/api-gateway-guide/traefik-kong-apisix-benchmark-method)[63. Amazon API Gateway Explained: Deployment Models, Trade-offs, and Use Cases](https://api7.ai/learning-center/api-gateway-guide/amazon-api-gateway-explained)[64. API Gateway and Istio: Clear North-South and East-West Boundaries](https://api7.ai/learning-center/api-gateway-guide/api-gateway-istio)[65. API Gateway with NGINX: Layering, Ownership, and Migration Patterns](https://api7.ai/learning-center/api-gateway-guide/api-gateway-nginx)[66. API Gateway with Envoy: Deployment Patterns and Policy Ownership](https://api7.ai/learning-center/api-gateway-guide/api-gateway-envoy)[67. API Gateway with Cloudflare API Shield: Edge and Origin Security Boundaries](https://api7.ai/learning-center/api-gateway-guide/api-gateway-cloudflare-api-shield)[68. Apigee vs MuleSoft vs Amazon API Gateway: A Decision Framework](https://api7.ai/learning-center/api-gateway-guide/apigee-mulesoft-amazon-api-gateway)[69. Should an API Gateway Connect Directly to a Database? Patterns and Risks](https://api7.ai/learning-center/api-gateway-guide/api-gateway-database-access-patterns)[70. API Gateway Architecture for Large-Scale SaaS Platforms](https://api7.ai/learning-center/api-gateway-guide/api-gateway-large-scale-saas-architecture)

08 Industry Applications and Integrations

[View this topic · 10](https://api7.ai/learning-center/api-gateway-guide?topic=applications)[71. API Gateway CI/CD: Validation, Promotion, and Safe Rollback](https://api7.ai/learning-center/api-gateway-guide/api-gateway-ci-cd)[72. API Gateways for AI and ML Inference: Traffic, Security, and Observability](https://api7.ai/learning-center/api-gateway-guide/api-gateways-ai-ml-inference)[73. API Gateway Architecture for Financial Services: Controls and Failure Boundaries](https://api7.ai/learning-center/api-gateway-guide/api-gateway-financial-services)[74. API Gateway Architecture for E-Commerce: Checkout Reliability and Traffic Peaks](https://api7.ai/learning-center/api-gateway-guide/api-gateway-ecommerce)[75. API Gateways for Mobile Applications: Authentication, Payloads, and Versioning](https://api7.ai/learning-center/api-gateway-guide/api-gateways-mobile-applications)[76. API Gateways for Web3 Applications: RPC Traffic, Identity, and Abuse Controls](https://api7.ai/learning-center/api-gateway-guide/api-gateways-web3-applications)[77. OpenAPI-Driven API Gateway Operations: Import, Validation, and Drift Control](https://api7.ai/learning-center/api-gateway-guide/openapi-driven-api-gateway-operations)[78. gRPC-Web and gRPC Transcoding Through an API Gateway](https://api7.ai/learning-center/api-gateway-guide/grpc-web-grpc-transcoding-api-gateway)[79. API Gateway Pricing and Cost Optimization: A Workload-Based Model](https://api7.ai/learning-center/api-gateway-guide/api-gateway-pricing-cost-optimization)[80. Evaluating API Gateway Directions: Evidence and Architectural Impact](https://api7.ai/learning-center/api-gateway-guide/api-gateway-trends)

09 Advanced Gateway Applications

[View this topic · 10](https://api7.ai/learning-center/api-gateway-guide?topic=operations)[81. API Gateways in Zero Trust Architecture: Identity, Policy, and Limits](https://api7.ai/learning-center/api-gateway-guide/api-gateways-zero-trust-architecture)[82. API Gateway Log Analytics: Correlation, Queries, and Operational Signals](https://api7.ai/learning-center/api-gateway-guide/api-gateway-log-analytics)[83. From API Sprawl to Governed Delivery: The Gateway's Role in Modernization](https://api7.ai/learning-center/api-gateway-guide/api-gateway-modernization)[84. API Monetization at the Gateway: Plans, Metering, Entitlements, and Billing Boundaries](https://api7.ai/learning-center/api-gateway-guide/api-monetization-gateway)[85. Safe AI-Assisted API Gateway Optimization: Recommendations, Guardrails, and Approval](https://api7.ai/learning-center/api-gateway-guide/ai-assisted-api-gateway-optimization)[86. API Gateways for Low-Code and No-Code Integration: Governance and Safety](https://api7.ai/learning-center/api-gateway-guide/api-gateways-low-code-no-code-integration)[87. API Gateway and CIAM Integration: Token Validation, Consent, and Identity Context](https://api7.ai/learning-center/api-gateway-guide/api-gateway-ciam-integration)[88. Elastic API Gateway Scaling: Signals, Capacity, and Safe Scale-In](https://api7.ai/learning-center/api-gateway-guide/elastic-api-gateway-scaling)[89. Multi-Tenant SaaS API Gateways: Isolation, Quotas, and Tenant-Aware Policy](https://api7.ai/learning-center/api-gateway-guide/multi-tenant-saas-api-gateway-policy)[90. API Gateway DevSecOps: Policy as Code, Testing, and Runtime Feedback](https://api7.ai/learning-center/api-gateway-guide/api-gateway-devsecops)

10 Platform Engineering and Planning

[View this topic · 10](https://api7.ai/learning-center/api-gateway-guide?topic=platform-governance)[91. API Discovery and Documentation at the Gateway: Inventory, Ownership, and Drift](https://api7.ai/learning-center/api-gateway-guide/api-discovery-documentation-gateway)[92. WebAssembly Plugins for API Gateways: Portability, Isolation, and APISIX Boundaries](https://api7.ai/learning-center/api-gateway-guide/api-gateway-webassembly-plugins)[93. Monitoring API Gateways with Prometheus and Grafana: Metrics, Dashboards, and Alerts](https://api7.ai/learning-center/api-gateway-guide/monitor-api-gateways-prometheus-grafana)[94. API Gateway Reliability Engineering: SLOs, Failure Isolation, and Incident Response](https://api7.ai/learning-center/api-gateway-guide/api-gateway-reliability-engineering)[95. API Gateways for Edge AI Inference: Routing, Constraints, and Observability](https://api7.ai/learning-center/api-gateway-guide/api-gateways-edge-ai-inference)[96. Reducing Cloud Cost with API Gateway Controls: Measurement Before Optimization](https://api7.ai/learning-center/api-gateway-guide/reducing-cloud-cost-api-gateway-controls)[97. Improving API Developer Experience with Gateway Standards and Self-Service](https://api7.ai/learning-center/api-gateway-guide/improving-api-developer-experience-gateway-self-service)[98. API Gateway Change Management: Compatibility, Progressive Delivery, and Rollback](https://api7.ai/learning-center/api-gateway-guide/api-gateway-change-management-rollback)[99. Operating Serverless APIs: Cold Starts, Idempotency, and Asynchronous Handoffs](https://api7.ai/learning-center/api-gateway-guide/operating-serverless-apis-gateway)[100. Planning an API Gateway Roadmap for the Next Five Years](https://api7.ai/learning-center/api-gateway-guide/planning-api-gateway-roadmap-next-five-years)

[API Gateway Guide](https://api7.ai/learning-center/api-gateway-guide)[Gateway Fundamentals](https://api7.ai/learning-center/api-gateway-guide?topic=fundamentals)

On this page

On this page

- [What Is an API Gateway?](#what-is-an-api-gateway)

- [How Does an API Gateway Work?](#how-does-an-api-gateway-work)

  - [Step-by-Step Request Flow](#step-by-step-request-flow)
  - [The Plugin Architecture](#the-plugin-architecture)

- [API Gateway Architecture Patterns](#api-gateway-architecture-patterns)

  - [Single Gateway (Edge Gateway)](#single-gateway-edge-gateway)
  - [Backend for Frontend (BFF)](#backend-for-frontend-bff)
  - [Two-Tier Gateway](#two-tier-gateway)

- [Core API Gateway Features](#core-api-gateway-features)

  - [Authentication and Authorization](#authentication-and-authorization)
  - [Rate Limiting and Traffic Control](#rate-limiting-and-traffic-control)
  - [Load Balancing](#load-balancing)
  - [Request and Response Transformation](#request-and-response-transformation)
  - [Observability](#observability)

- [API Gateway vs Related Technologies](#api-gateway-vs-related-technologies)

  - [API Gateway vs Reverse Proxy](#api-gateway-vs-reverse-proxy)
  - [API Gateway vs API Management](#api-gateway-vs-api-management)
  - [API Gateway vs Service Mesh](#api-gateway-vs-service-mesh)

- [API Gateway Use Cases](#api-gateway-use-cases)

  - [Microservices Architecture](#microservices-architecture)
  - [Mobile and IoT Backends](#mobile-and-iot-backends)
  - [Multi-Cloud and Hybrid Deployments](#multi-cloud-and-hybrid-deployments)
  - [AI and LLM Applications](#ai-and-llm-applications)
  - [API Monetization](#api-monetization)
  - [Legacy Modernization](#legacy-modernization)

- [Choosing an API Gateway](#choosing-an-api-gateway)

  - [Open-Source Options](#open-source-options)
  - [Cloud-Managed Options](#cloud-managed-options)
  - [How to Choose](#how-to-choose)

- [Getting Started with an API Gateway](#getting-started-with-an-api-gateway)

  - [1. Install APISIX](#1-install-apisix)
  - [2. Create an Upstream (Backend Service)](#2-create-an-upstream-backend-service)
  - [3. Create a Route with Plugins](#3-create-a-route-with-plugins)
  - [4. Create a Consumer with an API Key](#4-create-a-consumer-with-an-api-key)
  - [5. Test](#5-test)

- [API Gateway Software Capabilities](#api-gateway-software-capabilities)

- [Next Steps](#next-steps)

- [FAQ](#faq)

  - [What is an API gateway in simple terms?](#what-is-an-api-gateway-in-simple-terms)
  - [Do I need an API gateway?](#do-i-need-an-api-gateway)
  - [What is the difference between an API gateway and a load balancer?](#what-is-the-difference-between-an-api-gateway-and-a-load-balancer)
  - [Is an API gateway the same as a reverse proxy?](#is-an-api-gateway-the-same-as-a-reverse-proxy)
  - [What is the best open-source API gateway?](#what-is-the-best-open-source-api-gateway)
  - [Can an API gateway replace a service mesh?](#can-an-api-gateway-replace-a-service-mesh)
  - [How does an API gateway handle security?](#how-does-an-api-gateway-handle-security)
  - [What is an AI gateway?](#what-is-an-ai-gateway)

- [Further Reading](#further-reading)

Article 1

# What Is an API Gateway? API Gateway Software and Use Cases

API7.ai

February 6, 2025

An **API gateway** is a runtime layer between clients and backend services. It acts as a single entry point for API traffic: it receives a request, applies cross-cutting policies such as authentication, rate limiting, and logging, routes the request to the correct service, and returns the response. In a microservices architecture, clients no longer need to discover or communicate with every service directly.

| Quick Facts             | Details                                                            |
| ----------------------- | ------------------------------------------------------------------ |
| **What It Is**          | A reverse proxy specialized for API traffic management             |
| **Primary Function**    | Single entry point that routes, secures, and manages API requests  |
| **Core Features**       | Routing, authentication, rate limiting, load balancing, monitoring |
| **Where It Sits**       | Between API clients and backend services                           |
| **Used In**             | Microservices, cloud-native apps, mobile backends, AI/ML platforms |
| **Open-Source Options** | Apache APISIX, Kong, Traefik, Envoy, KrakenD                       |
| **Cloud Options**       | AWS API Gateway, Azure API Management, Google Apigee               |

## What Is an API Gateway?

An API gateway is infrastructure software that manages the flow of API requests between clients (web apps, mobile apps, partner systems, IoT devices) and backend services. Instead of each client calling each microservice directly, all requests pass through the gateway.

The gateway handles concerns that every API needs but no individual service should implement on its own:

- **Request routing** — Direct each request to the correct backend service based on URL path, headers, or request content
- **Authentication and authorization** — Verify API keys, JWT tokens, or OAuth credentials before forwarding requests
- **Rate limiting** — Cap the number of requests per client to prevent abuse and protect backend resources
- **Load balancing** — Distribute requests across multiple instances of a service
- **Request/response transformation** — Modify headers, rewrite URLs, convert between protocols (REST to gRPC)
- **Caching** — Store and serve frequently requested responses without hitting the backend
- **Monitoring and logging** — Capture metrics, traces, and access logs for every request

```
graph LR
    C1[Web App] --> GW[API Gateway]
    C2[Mobile App] --> GW
    C3[Partner API] --> GW
    C4[IoT Device] --> GW
    GW --> S1[User Service]
    GW --> S2[Order Service]
    GW --> S3[Payment Service]
    GW --> S4[Inventory Service]
    GW --> S5[AI/ML Service]
```

Without a gateway, each client must discover and connect to each backend service individually, handle authentication differently per service, and implement retry logic, circuit breaking, and load balancing on its own. The API gateway centralizes all of this into one manageable layer.

## How Does an API Gateway Work?

When a client makes an API request, the gateway processes it through a pipeline of steps before forwarding it to the backend:

```
sequenceDiagram
    participant C as Client
    participant G as API Gateway
    participant P as Plugin Pipeline
    participant U as Upstream Service

    C->>G: HTTP Request (GET /api/orders/123)
    G->>P: 1. Route matching
    P->>P: 2. Authentication (verify JWT)
    P->>P: 3. Rate limit check
    P->>P: 4. Request transformation
    G->>U: Forward to Order Service
    U-->>G: Response (200 OK + JSON)
    G->>P: 5. Response transformation
    P->>P: 6. Logging & metrics
    G-->>C: Return response to client
```

### Step-by-Step Request Flow

1. **Route matching** — The gateway matches the incoming URL path and HTTP method against configured routes. `GET /api/orders/123` maps to the Order Service, while `POST /api/payments` maps to the Payment Service.
2. **Plugin execution (request phase)** — Configured plugins run in order. An authentication plugin verifies the JWT token. A rate-limiting plugin checks whether the client has exceeded its quota. A request transformation plugin may add headers or modify the body.
3. **Upstream forwarding** — The gateway selects a healthy backend instance using a load balancing algorithm (round-robin, least connections, consistent hashing) and forwards the request.
4. **Response processing** — The backend response passes back through the plugin pipeline. Logging plugins record metrics. Response transformation plugins may strip internal headers or modify the response format.
5. **Client response** — The gateway returns the final response to the client, including any added headers (rate limit counters, correlation IDs).

### The Plugin Architecture

Modern API gateways use a **plugin architecture** that makes functionality modular and extensible. Each cross-cutting concern — authentication, rate limiting, caching, logging — is implemented as a separate plugin that can be enabled or disabled per route, per service, or globally.

[Apache APISIX](https://apisix.apache.org/), for example, ships with 80+ built-in plugins and supports custom plugins written in Lua, Go, Java, Python, or WebAssembly. This means you can add new capabilities without modifying gateway core code.

```
# Example: Apache APISIX route with plugins
routes:
  - uri: /api/v1/orders/*
    upstream:
      nodes:
        "order-service:8080": 1
      type: roundrobin
    plugins:
      jwt-auth: {}
      limit-req:
        rate: 100
        burst: 50
        rejected_code: 429
      proxy-rewrite:
        regex_uri: ["^/api/v1/orders/(.*)", "/orders/$1"]
      prometheus: {}
```

This configuration creates a route that:

- Matches requests to `/api/v1/orders/*`
- Requires JWT authentication
- Limits to 100 requests/second with a burst of 50
- Rewrites the URI before forwarding
- Exposes Prometheus metrics

## API Gateway Architecture Patterns

API gateways can be deployed in different patterns depending on your architecture and scale.

### Single Gateway (Edge Gateway)

The simplest pattern: one gateway instance (or cluster) handles all external API traffic.

```
graph TD
    Internet[Internet] --> GW[API Gateway]
    GW --> S1[Service A]
    GW --> S2[Service B]
    GW --> S3[Service C]
```

**Best for:** Small to medium deployments, monolith-to-microservice transitions, simple architectures.

### Backend for Frontend (BFF)

Each client type (web, mobile, partner) gets its own gateway optimized for that client's needs. The web BFF might aggregate multiple API calls into a single response, while the mobile BFF returns smaller payloads optimized for bandwidth.

```
graph TD
    Web[Web App] --> GW1[Web BFF Gateway]
    Mobile[Mobile App] --> GW2[Mobile BFF Gateway]
    Partner[Partner] --> GW3[Partner Gateway]
    GW1 --> S1[Service A]
    GW1 --> S2[Service B]
    GW2 --> S1
    GW2 --> S3[Service C]
    GW3 --> S2
```

**Best for:** Organizations with diverse client types that have different API consumption patterns.

### Two-Tier Gateway

An external gateway handles north-south traffic (client-to-service), while an internal gateway or service mesh handles east-west traffic (service-to-service).

```
graph TD
    Internet[Internet] --> EGW[External API Gateway]
    EGW --> IGW[Internal Gateway / Service Mesh]
    IGW --> S1[Service A]
    IGW --> S2[Service B]
    IGW --> S3[Service C]
    S1 <--> S2
    S2 <--> S3
```

**Best for:** Large enterprises with both external APIs and complex internal service communication.

## Core API Gateway Features

### Authentication and Authorization

An API gateway centralizes authentication so individual services don't implement it themselves. Supported methods typically include:

| Method                                                                            | How It Works                                    | Best For                                 |
| --------------------------------------------------------------------------------- | ----------------------------------------------- | ---------------------------------------- |
| **[API Keys](https://api7.ai/blog/what-is-api-key-why-need-them-complete-guide)** | Client sends a key in header or query param     | Simple public APIs                       |
| **JWT (JSON Web Tokens)**                                                         | Self-contained signed tokens with claims        | Stateless auth in microservices          |
| **OAuth 2.0**                                                                     | Token-based delegated authorization with scopes | User-facing APIs with third-party access |
| **mTLS**                                                                          | Mutual TLS with client certificates             | Service-to-service, zero-trust           |
| **Basic Auth**                                                                    | Username/password in Authorization header       | Internal/development APIs                |
| **LDAP/OIDC**                                                                     | Enterprise directory integration                | Corporate environments                   |

The gateway verifies credentials, extracts identity information (user ID, roles, scopes), and passes it to backend services via headers — so services receive pre-authenticated requests.

### Rate Limiting and Traffic Control

API gateways enforce [rate limiting](https://api7.ai/blog/token-bucket-vs-leaky-best-rate-limiting-algorithm) to prevent abuse and protect backend infrastructure:

- **Per-consumer limits** — Each API key or user gets a separate quota
- **Per-route limits** — Expensive endpoints (e.g., AI inference) get lower limits
- **Global limits** — Cap total system throughput
- **Dynamic limits** — Adjust based on current system load

When a client exceeds the limit, the gateway returns `429 Too Many Requests` with a `Retry-After` header without the request ever reaching your backend.

### Load Balancing

The gateway distributes traffic across multiple backend instances using algorithms like:

- **Round-robin** — Requests cycle through backends sequentially
- **Weighted round-robin** — More traffic goes to more powerful instances
- **Least connections** — New requests go to the instance with fewest active connections
- **Consistent hashing** — Requests from the same client always go to the same instance (useful for caching)
- **EWMA (Exponential Weighted Moving Average)** — Routes to the instance with lowest latency

### Request and Response Transformation

API gateways can modify requests before forwarding them upstream and transform responses before returning them to clients. Common examples include:

- **URL rewriting** — Map external paths (`/api/v2/users`) to internal paths (`/users`)
- **Header injection** — Add correlation IDs, authentication context, or routing hints
- **Body transformation** — Convert between JSON and XML, add/remove fields
- **Protocol translation** — Accept REST requests from clients, forward as gRPC to backends

### Observability

- **Centralized Logging & Monitoring**: Provides insights into API usage, errors, and performance metrics.

Production API gateways integrate with monitoring and logging systems:

- **Metrics** — Request count, latency histograms, error rates per route (Prometheus, Datadog, StatsD)
- **Distributed tracing** — Inject trace headers for end-to-end request tracing (Jaeger, Zipkin, OpenTelemetry)
- **Access logging** — Structured logs for every request (Elasticsearch, Splunk, CloudWatch)
- **Alerting** — Trigger alerts when error rates spike or latency exceeds thresholds

## API Gateway vs Related Technologies

### API Gateway vs Reverse Proxy

**Example**: APISIX API gateway supports OAuth 2.0, mTLS, and [API key-based authentication](https://api7.ai/blog/what-is-api-key-why-need-them-complete-guide), ensuring secure access control.

A reverse proxy (Nginx, HAProxy) forwards requests to backend servers and handles SSL termination, caching, and load balancing. An API gateway does all of this **plus** API-specific features: authentication, rate limiting per consumer, request/response transformation, API versioning, and developer portal integration.

| Capability                  | Reverse Proxy | API Gateway |
| --------------------------- | ------------- | ----------- |
| Request routing             | Yes           | Yes         |
| SSL termination             | Yes           | Yes         |
| Load balancing              | Yes           | Yes         |
| Authentication (JWT, OAuth) | Limited       | Yes         |
| Per-consumer rate limiting  | No            | Yes         |
| API versioning              | No            | Yes         |
| Request transformation      | Limited       | Yes         |
| Developer portal            | No            | Yes         |
| Plugin ecosystem            | Limited       | Extensive   |

**In practice:** Many API gateways (APISIX, Kong) are built on top of reverse proxy technology (Nginx/OpenResty) and extend it with API-specific capabilities.

### API Gateway vs API Management

An **API gateway** is the runtime component that processes API traffic. **API management** is the broader discipline that includes the gateway plus:

- **Developer portal** — Documentation, API discovery, and self-service key management for developers
- **API lifecycle management** — Versioning, deprecation, and retirement workflows
- **Analytics & reporting** — Business-level insights into API adoption and usage trends
- **Monetization** — Billing integration, subscription tiers, and usage-based pricing
- **Governance & policy management** — Organization-wide API standards, compliance, and approval workflows

### API Gateway vs Service Mesh

An **API gateway** manages **north-south traffic** — requests from external clients entering your system. A **service mesh** (Istio, Linkerd) manages **east-west traffic** — communication between internal services.

| Aspect            | API Gateway                         | Service Mesh                    |
| ----------------- | ----------------------------------- | ------------------------------- |
| Traffic direction | North-south (external → internal)   | East-west (internal ↔ internal) |
| Deployment        | Centralized proxy                   | Sidecar per service             |
| Primary concern   | External API management             | Internal service communication  |
| Features          | Auth, rate limiting, transformation | mTLS, retry, circuit breaking   |
| Complexity        | Lower                               | Higher                          |

Many organizations use both: an API gateway at the edge and a service mesh internally. Some gateways like APISIX can also function in service mesh mode for east-west traffic.

## API Gateway Use Cases

### Microservices Architecture

The most common use case. When a monolith is decomposed into microservices, clients need a single entry point rather than discovering and communicating with dozens of individual services. The API gateway provides this entry point, handling routing, authentication, and aggregation.

### Mobile and IoT Backends

Mobile apps and IoT devices operate on unreliable networks with limited bandwidth. An API gateway can aggregate multiple backend calls into a single response (reducing round trips), compress responses, and cache frequently requested data — improving the mobile client experience.

Use [OAuth 2.0](https://oauth.net/2/), [JWT tokens](https://jwt.io/introduction), and [API keys](https://api7.ai/blog/what-is-api-key-why-need-them-complete-guide) to control access securely.

### Multi-Cloud and Hybrid Deployments

Organizations running services across AWS, Azure, GCP, and on-premises data centers use API gateways to provide a unified API surface regardless of where backend services are deployed. The gateway abstracts away the infrastructure topology from API consumers.

### AI and LLM Applications

Modern AI applications call multiple LLM providers (OpenAI, Anthropic, Google Gemini) with different API formats, pricing, and rate limits. An [AI Gateway](https://api7.ai/learning-center/api-gateway-guide/ai-gateway-vs-mcp-gateway-vs-api-gateway) extends the traditional API gateway with LLM-specific features: model routing, token-based rate limiting, cost tracking, prompt caching, and automatic failover between providers.

### API Monetization

SaaS companies that sell API access use gateways to enforce subscription tiers, track usage, and integrate with billing systems. Different API keys get different rate limits, feature access, and SLAs — all enforced at the gateway layer.

### Legacy Modernization

When modernizing legacy systems, an API gateway can sit in front of legacy services and expose them as modern REST or GraphQL APIs. The gateway handles protocol translation, request/response mapping, and security — without modifying the legacy system.

## Choosing an API Gateway

### Open-Source Options

| Gateway                                         | Language  | Performance                | Plugin System               | Kubernetes         | Key Strength                   |
| ----------------------------------------------- | --------- | -------------------------- | --------------------------- | ------------------ | ------------------------------ |
| **[Apache APISIX](https://apisix.apache.org/)** | Lua/Nginx | Very high (sub-ms latency) | 80+ plugins, multi-language | Ingress Controller | Performance, extensibility     |
| **Kong**                                        | Lua/Nginx | High                       | Plugin Hub                  | Ingress Controller | Ecosystem, enterprise features |
| **Envoy**                                       | C++       | Very high                  | Filter chain                | Istio integration  | Service mesh, gRPC native      |
| **Traefik**                                     | Go        | High                       | Middleware                  | Native CRDs        | Auto-discovery, simplicity     |
| **KrakenD**                                     | Go        | Very high                  | Declarative config          | Helm charts        | API aggregation, stateless     |

### Cloud-Managed Options

| Service                    | Provider   | Best For                               |
| -------------------------- | ---------- | -------------------------------------- |
| **AWS API Gateway**        | Amazon     | AWS-native applications                |
| **Azure API Management**   | Microsoft  | Azure ecosystem, enterprise governance |
| **Google Apigee**          | Google     | API monetization, multi-cloud          |
| **Cloudflare API Gateway** | Cloudflare | Edge computing, DDoS protection        |

### How to Choose

- **High performance + extensibility** → Apache APISIX or Envoy
- **Managed service, minimal ops** → AWS API Gateway or Azure APIM
- **Enterprise features + support** → [API7 Enterprise](https://api7.ai/enterprise) (built on APISIX) or Kong Enterprise
- **Kubernetes-native auto-discovery** → Traefik
- **API aggregation (BFF pattern)** → KrakenD
- **AI/LLM workloads** → [AISIX AI Gateway](https://api7.ai/ai-gateway) or custom Envoy filters

For a detailed side-by-side comparison, see our [API Gateway Comparison](https://api7.ai/api-gateway-comparison) page.

## Getting Started with an API Gateway

Here is a minimal example using Apache APISIX to set up an API gateway that routes, authenticates, and rate-limits an API:

### 1. Install APISIX

```
# Using Docker
curl https://raw.githubusercontent.com/apache/apisix-docker/master/quickstart/docker-compose.yml -o docker-compose.yml
docker compose up -d
```

### 2. Create an Upstream (Backend Service)

```
curl -i http://127.0.0.1:9180/apisix/admin/upstreams/1 -X PUT \
  -H "X-API-KEY: $APISIX_ADMIN_KEY" \
  -d '{
    "type": "roundrobin",
    "nodes": {
      "httpbin.org:80": 1
    }
  }'
```

### 3. Create a Route with Plugins

```
curl -i http://127.0.0.1:9180/apisix/admin/routes/1 -X PUT \
  -H "X-API-KEY: $APISIX_ADMIN_KEY" \
  -d '{
    "uri": "/api/*",
    "upstream_id": 1,
    "plugins": {
      "key-auth": {},
      "limit-req": {
        "rate": 10,
        "burst": 5,
        "rejected_code": 429
      },
      "proxy-rewrite": {
        "regex_uri": ["^/api/(.*)", "/$1"]
      }
    }
  }'
```

### 4. Create a Consumer with an API Key

```
curl -i http://127.0.0.1:9180/apisix/admin/consumers -X PUT \
  -H "X-API-KEY: $APISIX_ADMIN_KEY" \
  -d '{
    "username": "demo-user",
    "plugins": {
      "key-auth": {
        "key": "my-secret-key"
      }
    }
  }'
```

> **Note:** Replace `$APISIX_ADMIN_KEY` with the Admin API key configured in your `config.yaml`. The default key in Docker quickstart is `edd1c9f034335f136f87ad84b625c8f1` — always change it in production.

### 5. Test

```
# Without API key — rejected
curl -i http://127.0.0.1:9080/api/get
# HTTP/1.1 401 Unauthorized

# With API key — success
curl -i http://127.0.0.1:9080/api/get \
  -H "apikey: my-secret-key"
# HTTP/1.1 200 OK
```

In under 5 minutes, you have an API gateway that authenticates requests and enforces rate limits — the two most critical production concerns.

## API Gateway Software Capabilities

| Area               | What It Means                                      | Why It Matters                                |
| ------------------ | -------------------------------------------------- | --------------------------------------------- |
| Traffic management | Routing, load balancing, retries, upstream health  | Keeps services reachable and resilient        |
| Security           | Auth, authorization, rate limits, IP controls, TLS | Protects APIs before traffic reaches services |
| Operations         | Metrics, logs, tracing, config management          | Improves reliability and troubleshooting      |

For selection help, see [top API gateways compared](https://api7.ai/top-11-api-gateways-platforms-compared) and [API gateway vs load balancer](https://api7.ai/blog/api-gateway-vs-load-balancer-difference).

## Next Steps

Explore more topics in our API Gateway Guide series:

- [AI Gateway vs MCP Gateway vs API Gateway](https://api7.ai/learning-center/api-gateway-guide/ai-gateway-vs-mcp-gateway-vs-api-gateway) — Understand how AI gateways and MCP gateways differ from traditional API gateways
- [How API Gateways Enhance MCP Servers](https://api7.ai/learning-center/api-gateway-guide/api-gateway-enhance-mcp-server) — Why MCP servers need API gateway security and traffic management
- [RESTful API Best Practices](https://api7.ai/learning-center/api-101/restful-api-best-practices) — Design patterns for building secure, scalable REST APIs behind an API gateway
- [HTTP Methods in APIs](https://api7.ai/learning-center/api-101/http-methods-in-apis) — Deep dive into GET, POST, PUT, DELETE and how gateways handle each method

Follow [our LinkedIn](https://sg.linkedin.com/company/api7-ai) for valuable insights delivered straight to your inbox!

## FAQ

### What is an API gateway in simple terms?

An API gateway is a single front door for all your APIs. Every request from clients (web apps, mobile apps, partners) goes through this gateway first. It checks who is making the request, whether they are allowed, whether they are making too many requests, and then forwards the request to the right backend service. Think of it like a hotel reception desk — all guests check in through one desk, which handles room assignments, key cards, and requests.

### Do I need an API gateway?

If you have more than one backend service or expose APIs to external consumers, yes. An API gateway centralizes authentication, rate limiting, and monitoring so each service doesn't have to implement these independently. For a single monolithic application with no external API consumers, a simple reverse proxy may be sufficient.

### What is the difference between an API gateway and a load balancer?

A [load balancer](https://api7.ai/blog/api-gateway-vs-load-balancer) distributes traffic across multiple server instances for availability and performance. An API gateway does this **plus** API-specific functions: authentication, rate limiting per consumer, request transformation, API versioning, and observability. Load balancers work at the network/transport layer (L4); API gateways work at the application layer (L7) with API-specific intelligence.

### Is an API gateway the same as a reverse proxy?

No. A reverse proxy forwards requests to backend servers and handles basic concerns like SSL termination and caching. An API gateway is a reverse proxy with additional API-specific capabilities: consumer-level authentication, per-API rate limiting, request/response transformation, and integration with API management platforms. Most API gateways are built on reverse proxy foundations (e.g., APISIX and Kong use Nginx/OpenResty).

### What is the best open-source API gateway?

The best choice depends on your requirements. **[Apache APISIX](https://apisix.apache.org/)** offers the best performance and extensibility with 80+ plugins and multi-language support. **Kong** has the largest ecosystem and enterprise feature set. **Envoy** is ideal for service mesh integration and gRPC-native workloads. **Traefik** provides the simplest Kubernetes auto-discovery. For enterprise support on APISIX, [API7 Enterprise](https://api7.ai/enterprise) adds a management console, RBAC, and multi-cluster management.

### Can an API gateway replace a service mesh?

Not entirely. An API gateway handles **north-south** traffic (external clients accessing your APIs), while a service mesh handles **east-west** traffic (internal service-to-service communication). They solve different problems. However, some gateways like APISIX can handle both north-south and east-west traffic, reducing the need for a separate service mesh in simpler architectures.

### How does an API gateway handle security?

An API gateway centralizes security enforcement. It authenticates requests (API keys, JWT, OAuth 2.0, mTLS), authorizes access based on roles or scopes, enforces rate limits to prevent abuse, blocks malicious requests (IP blacklisting, WAF integration), and encrypts all traffic with TLS. Backend services receive pre-authenticated requests, so they can focus on business logic rather than security concerns.

### What is an AI gateway?

An [AI gateway](https://api7.ai/learning-center/api-gateway-guide/ai-gateway-vs-mcp-gateway-vs-api-gateway) is a specialized API gateway designed for AI and LLM workloads. It adds capabilities specific to AI: model routing across multiple LLM providers, token-based rate limiting (TPM/RPM), prompt caching, cost tracking per model and consumer, semantic caching, and automatic failover between AI providers. [AISIX](https://api7.ai/ai-gateway) is an AI-native gateway built on Apache APISIX.

## Further Reading

- [API Gateway vs Load Balancer](https://api7.ai/blog/api-gateway-vs-load-balancer)
- [API Gateway vs Reverse Proxy](https://api7.ai/blog/api-gateway-vs-reverse-proxy)
- [10 Use Cases of API Gateway](https://api7.ai/blog/api-gateway-use-cases)
- [What Is an AI Gateway?](https://api7.ai/learning-center/api-gateway-guide/ai-gateway-vs-mcp-gateway-vs-api-gateway)
- [What Is an MCP Gateway?](https://api7.ai/learning-center/api-gateway-guide/api-gateway-enhance-mcp-server)
- [What Is Rate Limiting?](https://api7.ai/blog/token-bucket-vs-leaky-best-rate-limiting-algorithm)
- [What Is an API Key?](https://api7.ai/blog/what-is-api-key-why-need-them-complete-guide)
- [HTTP Methods in APIs](https://api7.ai/learning-center/api-101/http-methods-in-apis)
- [RESTful API Best Practices](https://api7.ai/learning-center/api-101/restful-api-best-practices)

[Next article**Why Do Modern Architectures Need an API Gateway?**](https://api7.ai/learning-center/api-gateway-guide/why-do-modern-architectures-need-api-gateway)

On this page

- [What Is an API Gateway?](#what-is-an-api-gateway)

- [How Does an API Gateway Work?](#how-does-an-api-gateway-work)

  - [Step-by-Step Request Flow](#step-by-step-request-flow)
  - [The Plugin Architecture](#the-plugin-architecture)

- [API Gateway Architecture Patterns](#api-gateway-architecture-patterns)

  - [Single Gateway (Edge Gateway)](#single-gateway-edge-gateway)
  - [Backend for Frontend (BFF)](#backend-for-frontend-bff)
  - [Two-Tier Gateway](#two-tier-gateway)

- [Core API Gateway Features](#core-api-gateway-features)

  - [Authentication and Authorization](#authentication-and-authorization)
  - [Rate Limiting and Traffic Control](#rate-limiting-and-traffic-control)
  - [Load Balancing](#load-balancing)
  - [Request and Response Transformation](#request-and-response-transformation)
  - [Observability](#observability)

- [API Gateway vs Related Technologies](#api-gateway-vs-related-technologies)

  - [API Gateway vs Reverse Proxy](#api-gateway-vs-reverse-proxy)
  - [API Gateway vs API Management](#api-gateway-vs-api-management)
  - [API Gateway vs Service Mesh](#api-gateway-vs-service-mesh)

- [API Gateway Use Cases](#api-gateway-use-cases)

  - [Microservices Architecture](#microservices-architecture)
  - [Mobile and IoT Backends](#mobile-and-iot-backends)
  - [Multi-Cloud and Hybrid Deployments](#multi-cloud-and-hybrid-deployments)
  - [AI and LLM Applications](#ai-and-llm-applications)
  - [API Monetization](#api-monetization)
  - [Legacy Modernization](#legacy-modernization)

- [Choosing an API Gateway](#choosing-an-api-gateway)

  - [Open-Source Options](#open-source-options)
  - [Cloud-Managed Options](#cloud-managed-options)
  - [How to Choose](#how-to-choose)

- [Getting Started with an API Gateway](#getting-started-with-an-api-gateway)

  - [1. Install APISIX](#1-install-apisix)
  - [2. Create an Upstream (Backend Service)](#2-create-an-upstream-backend-service)
  - [3. Create a Route with Plugins](#3-create-a-route-with-plugins)
  - [4. Create a Consumer with an API Key](#4-create-a-consumer-with-an-api-key)
  - [5. Test](#5-test)

- [API Gateway Software Capabilities](#api-gateway-software-capabilities)

- [Next Steps](#next-steps)

- [FAQ](#faq)

  - [What is an API gateway in simple terms?](#what-is-an-api-gateway-in-simple-terms)
  - [Do I need an API gateway?](#do-i-need-an-api-gateway)
  - [What is the difference between an API gateway and a load balancer?](#what-is-the-difference-between-an-api-gateway-and-a-load-balancer)
  - [Is an API gateway the same as a reverse proxy?](#is-an-api-gateway-the-same-as-a-reverse-proxy)
  - [What is the best open-source API gateway?](#what-is-the-best-open-source-api-gateway)
  - [Can an API gateway replace a service mesh?](#can-an-api-gateway-replace-a-service-mesh)
  - [How does an API gateway handle security?](#how-does-an-api-gateway-handle-security)
  - [What is an AI gateway?](#what-is-an-ai-gateway)

- [Further Reading](#further-reading)
