Skip to main content

API Gateway

The API Gateway provides enterprise-grade traffic management for your entire API ecosystem. Handle REST, Kafka, WebSocket, MQTT, and beyond with full governance and control.

Key Features

  • Multi-Protocol Support - REST, WebSocket, MQTT, Kafka, and more
  • Intelligent Routing - Path-based (prefix, exact, regex) and method-based routing
  • Load Balancing - Round-robin, weighted, IP-hash, least-connections
  • Rate Limiting - Per-route and global rate limiting
  • Health Checks - Automatic backend monitoring and failover
  • Request Transformation - Modify headers, query params, and paths
  • Circuit Breaker - Automatic failure detection and recovery

Creating a Gateway

Via Web UI

  1. Navigate to Gateways in the sidebar
  2. Click Create Gateway
  3. Enter:
    • Name: Descriptive name for your gateway
    • Subdomain: URL prefix (e.g., myapimyapi-gw.free-tunnelapi.app)
    • Description: Optional description

Via API

curl -X POST https://api.tunnelapi.in/api/gateways \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"name": "My API Gateway",
"subdomain": "myapi",
"description": "Production API gateway"
}'

Managing Routes

Routes define how incoming requests are matched and forwarded to backends.

{
"name": "API Route",
"path": "/api/v1",
"pathType": "prefix", // prefix, exact, regex
"methods": ["GET", "POST"],
"backends": [
{
"url": "http://backend1:3000",
"weight": 70,
"healthCheck": {
"enabled": true,
"path": "/health",
"interval": 30000
}
},
{
"url": "http://backend2:3000",
"weight": 30
}
],
"loadBalancing": {
"strategy": "weighted"
}
}

Path Types

TypeBehaviorExample
prefixMatches path prefix/api matches /api, /api/users
exactExact path match/api matches only /api
regexRegular expression/api/v[0-9]+

Rate Limiting

Configure rate limits per gateway or per route:

{
"rateLimit": {
"enabled": true,
"requestsPerSecond": 100,
"burstSize": 150
}
}

Request Transformation

Transform requests before forwarding:

{
"transformations": {
"addHeaders": {
"X-Gateway-ID": "{{gateway.id}}",
"X-Request-ID": "{{uuid}}"
},
"removeHeaders": ["X-Internal-Header"],
"modifyHeaders": {
"Host": "internal-service.local"
}
}
}

Analytics

Monitor your gateway traffic:

  • Request Count - Total requests processed
  • Bytes In/Out - Bandwidth usage
  • Error Count - Failed requests
  • Average Latency - Response time