> ## Documentation Index
> Fetch the complete documentation index at: https://docs.apinizer.com/llms.txt
> Use this file to discover all available pages before exploring further.

# API Gateway

> API Gateway (API Gateway), the main component in the Data Plane (Data Plane) layer of the Apinizer platform where API traffic is processed, routed, and policies are applied. It is a high-performance component that handles client requests, applies security policies, manages traffic, and routes to backend APIs.

## API Gateway Concept

<CardGroup cols={2}>
  <Card title="High Performance" icon="gauge">
    Low latency and high throughput
  </Card>

  <Card title="Security" icon="shield">
    Authentication, Authorization, mTLS
  </Card>

  <Card title="Traffic Management" icon="route">
    Load balancing, rate limiting, failover
  </Card>

  <Card title="Scalability" icon="arrows-up-down">
    Horizontal scaling support
  </Card>
</CardGroup>

## API Gateway Components

<AccordionGroup>
  <Accordion title="Request Handling">
    * Handling client requests
    * TLS/SSL termination
    * Request parsing and validation
  </Accordion>

  <Accordion title="Policy Enforcement">
    * Applying pre-flow policies
    * Evaluating conditional policies
    * Applying post-flow policies
  </Accordion>

  <Accordion title="Routing">
    * Upstream Target selection
    * Load balancing application
    * Failover mechanism
  </Accordion>
</AccordionGroup>

### Worker Modules

<CardGroup cols={2}>
  <Card title="Environment Isolation" icon="layer-group">
    Each Worker belongs to an environment
  </Card>

  <Card title="Horizontal Scaling" icon="arrows-up-down">
    Scaling with multiple Workers
  </Card>

  <Card title="High Availability" icon="heart-pulse">
    Load balancing among Workers
  </Card>

  <Card title="Independent Operation" icon="server">
    Workers operate independently
  </Card>
</CardGroup>

### Local Cache

<CardGroup cols={2}>
  <Card title="Configuration Cache" icon="gear">
    Configurations loaded via Management API

    API Proxy configurations and settings.
  </Card>

  <Card title="Policy Cache" icon="shield">
    Policy definitions

    All policy definitions and configurations.
  </Card>

  <Card title="Token Cache" icon="key">
    OAuth2/JWT tokens

    Token validation results and token information.
  </Card>

  <Card title="Metadata Cache" icon="info-circle">
    API Proxy metadata information

    API Proxy information and routing metadata.
  </Card>
</CardGroup>

<Info>
  **Distributed Cache Access:**

  API Gateway uses Distributed Cache (Hazelcast) for shared data such as throttling, quota, and OAuth2 tokens. Cache Servers can run in different Kubernetes namespaces from Gateway pods. Gateway pods can access cache servers in other namespaces using Kubernetes service discovery (e.g., `http://cache-http-service.apinizer-cache.svc.cluster.local:8090`). This provides more flexible infrastructure management. For more information about Distributed Cache, see the [Cache Component](/en/concepts/core-components/cache-component) page.
</Info>

### Token Provider API

<CardGroup cols={3}>
  <Card title="Token Generation" icon="plus-circle">
    Access token and refresh token generation

    Creation of OAuth2 and JWT tokens.
  </Card>

  <Card title="Token Validation" icon="check-circle">
    Token validation

    Checking token validity.
  </Card>

  <Card title="Token Revocation" icon="trash">
    Token revocation

    Revoking and invalidating tokens.
  </Card>
</CardGroup>

## API Gateway Features

### Security

<CardGroup cols={2}>
  <Card title="Authentication" icon="key">
    * OAuth2 / OIDC
    * JWT
    * Basic / Digest Authentication
    * mTLS
  </Card>

  <Card title="Authorization" icon="lock">
    * IP Whitelist/Blacklist
    * API Key control
    * Role-based Access Control
  </Card>

  <Card title="TLS/SSL" icon="shield-halved">
    * TLS/SSL termination
    * SNI support
    * Certificate management
  </Card>

  <Card title="Data Protection" icon="eye-slash">
    * Data masking
    * Encryption
    * PII protection
  </Card>
</CardGroup>

### Traffic Management

<AccordionGroup>
  <Accordion title="Load Balancing">
    * Round Robin
    * Least Connections
    * Weighted Round Robin

    <Tip>
      For detailed information about load balancing strategies, see the [Routing and Upstream](/en/concepts/core-concepts/routing-and-upstream#load-balancing-strategies) page.
    </Tip>
  </Accordion>

  <Accordion title="Rate Limiting">
    * API-based rate limiting
    * User-based rate limiting
    * IP-based rate limiting
    * Quota management
  </Accordion>

  <Accordion title="Failover">
    * Automatic failover
    * Health check
    * Circuit breaker
  </Accordion>
</AccordionGroup>

### Message Processing

<CardGroup cols={2}>
  <Card title="Transformation" icon="wand-magic-sparkles">
    * JSON ↔ XML conversion
    * Message enrichment
    * Field mapping
  </Card>

  <Card title="Validation" icon="check-circle">
    * JSON Schema validation
    * XML Schema validation
    * Message size validation
  </Card>

  <Card title="Routing" icon="route">
    * Conditional routing
    * Content-based routing
    * Version-based routing
  </Card>

  <Card title="Logging" icon="file-lines">
    * Request/Response logging
    * Audit logging
    * Error logging
  </Card>
</CardGroup>

## API Gateway and API Manager Relationship

API Gateway receives configuration from API Manager and processes traffic. Workflow:

```
API Manager (Control Plane)
   │
   │ 1. Configuration Management
   │ 2. Deployment
   │
   ▼
API Gateway (Data Plane)
   │
   │ 3. Loading into Local Cache
   │ 4. Request Handling
   │ 5. Traffic Processing
   │ 6. Sending Metrics
   │
   ▼
Backend API / Client
```

<CardGroup cols={3}>
  <Card title="1. Configuration" icon="gear">
    API Proxy configuration is done in API Manager

    All configurations are managed centrally.
  </Card>

  <Card title="2. Deployment" icon="rocket">
    Configuration is deployed to API Gateways

    Configurations are distributed to all gateways.
  </Card>

  <Card title="3. Cache" icon="memory">
    API Gateway loads configuration into Local Cache

    Cached locally for performance.
  </Card>

  <Card title="4. Request" icon="arrow-right">
    Client requests come to API Gateway

    Client requests are routed to gateway.
  </Card>

  <Card title="5. Processing" icon="cog">
    API Gateway processes traffic using configuration

    Policies are applied and routing is done.
  </Card>

  <Card title="6. Metrics" icon="chart-bar">
    Metrics are sent to API Manager

    Performance and usage metrics are collected.
  </Card>
</CardGroup>

<Info>
  This collaboration between API Manager and API Gateway balances central management and high-performance traffic processing.
</Info>

## API Gateway Performance Features

<CardGroup cols={2}>
  <Card title="Low Latency" icon="clock">
    * Optimized request handling
    * Local cache usage
    * Async processing
  </Card>

  <Card title="High Throughput" icon="gauge">
    * Non-blocking I/O
    * Connection pooling
    * Efficient resource usage
  </Card>

  <Card title="Scalability" icon="arrows-up-down">
    * Horizontal scaling
    * Auto-scaling
    * Load balancing
  </Card>

  <Card title="High Availability" icon="heart-pulse">
    * Failover mechanism
    * Health check
    * Redundancy
  </Card>
</CardGroup>

## Next Steps

<CardGroup cols={2}>
  <Card title="API Manager" icon="gear" href="/en/concepts/core-components/api-manager">
    Learn about API Manager component
  </Card>

  <Card title="Technical Architecture" icon="diagram-project" href="/en/concepts/architecture">
    Learn about Technical Architecture structure
  </Card>

  <Card title="Routing and Upstream" icon="route" href="/en/concepts/core-concepts/routing-and-upstream">
    Learn about routing and upstream concepts
  </Card>

  <Card title="Message Processing and Policy Application" icon="shield" href="/en/concepts/core-concepts/message-processing-and-policy-application">
    Learn about message processing flow
  </Card>
</CardGroup>
