Zero-config API gateway - Turn any local service into REST API instantly
API-Bridge is a lightweight, high-performance API gateway that allows you to instantly expose any local service as a REST API with zero configuration. Whether you're developing microservices, integrating legacy systems, or building API proxies, API-Bridge provides a simple yet powerful solution.
- 🚀 Zero Configuration: Start proxying services with a single command
- ⚡ High Performance: Built on FastAPI and Uvicorn for maximum throughput
- 🔐 Security First: Built-in API key management and JWT authentication
- 📊 Observability: Prometheus metrics and real-time monitoring
- 🔄 Smart Caching: Automatic response caching with TTL support
- ⚖️ Load Balancing: Weighted round-robin backend selection
API-Bridge was inspired by the growing need for simple, lightweight API gateways in microservice architectures. While existing solutions like Kong and Nginx are powerful, they often require complex configuration. API-Bridge fills the gap by providing essential gateway features with minimal setup.
- Start proxying any service with one command
- Automatic route discovery and configuration
- Support for HTTP/HTTPS backends
- API Key Management: Create, revoke, and manage API keys dynamically
- JWT Support: Token-based authentication with configurable expiration
- Flexible Authorization: Role-based access control
- Prometheus Metrics: Export metrics for monitoring stacks
- Request Statistics: Track latency, throughput, and error rates
- Health Checks: Automatic backend health monitoring
- Response Caching: Cache GET responses with configurable TTL
- Cache Invalidation: Programmatic cache management
- Cache Hit Metrics: Monitor cache effectiveness
- Weighted Round-Robin: Distribute traffic across backends
- Health-Aware Routing: Skip unhealthy backends automatically
- Dynamic Backend Management: Add/remove backends at runtime
- Rich CLI: Beautiful command-line interface with progress indicators
- Hot Reload: Auto-restart during development
- Comprehensive Logging: Structured JSON logging
- Python 3.8 or higher
- pip or pipenv
# Install from PyPI
pip install api-bridge
# Or install from source
git clone https://github.com/gitstq/api-bridge.git
cd api-bridge
pip install -e ".[dev]"# Start the gateway with default settings
api-bridge start
# Proxy a specific service
api-bridge proxy https://api.example.com --path /api
# Start with custom port
api-bridge start --port 3000 --reload
# Generate configuration file
api-bridge config --output .envOnce running, the following endpoints are available:
| Endpoint | Description |
|---|---|
http://localhost:8080 |
Main proxy endpoint |
http://localhost:8080/health |
Health check |
http://localhost:8080/stats |
Gateway statistics |
http://localhost:8080/metrics |
Prometheus metrics |
API-Bridge can be configured via environment variables or a .env file:
# Server settings
API_BRIDGE_HOST=0.0.0.0
API_BRIDGE_PORT=8080
# Security
API_BRIDGE_API_KEYS=your-key-1,your-key-2
API_BRIDGE_JWT_SECRET=your-secret
# Features
API_BRIDGE_CACHE_ENABLED=true
API_BRIDGE_CACHE_TTL=300
API_BRIDGE_RATE_LIMIT_ENABLED=true# Add a route via API
curl -X POST http://localhost:8080/routes \
-H "Content-Type: application/json" \
-d '{
"path": "/my-service",
"backends": [
{
"name": "backend-1",
"url": "http://localhost:3001",
"weight": 2
},
{
"name": "backend-2",
"url": "http://localhost:3002",
"weight": 1
}
]
}'
# List all routes
curl http://localhost:8080/routes
# Delete a route
curl -X DELETE http://localhost:8080/routes/my-service# Create an API key
curl -X POST http://localhost:8080/keys \
-H "Content-Type: application/json" \
-d '{
"name": "my-app",
"permissions": ["read", "write"],
"expires_in_days": 30
}'
# List API keys
curl http://localhost:8080/keys
# Revoke an API key
curl -X DELETE http://localhost:8080/keys/{key_id}# Start API-Bridge
api-bridge start
# In another terminal, test the proxy
curl http://localhost:8080/httpbin/get
curl -X POST http://localhost:8080/httpbin/post \
-H "Content-Type: application/json" \
-d '{"test": "data"}'API-Bridge prioritizes ease of use. Complex configuration is optional - the gateway works out of the box with sensible defaults.
Built on FastAPI and Uvicorn, API-Bridge handles thousands of concurrent connections with minimal overhead.
Authentication and rate limiting are enabled by default. Production deployments are secure from day one.
Every request is tracked. Prometheus metrics provide insights into traffic patterns and performance.
- Core proxy functionality
- API key management
- Response caching
- Prometheus metrics
- CLI interface
- Load balancing
- WebSocket proxy support
- GraphQL gateway features
- Plugin system
- Kubernetes operator
- Web-based dashboard
- gRPC proxy support
- Service mesh integration
FROM python:3.11-slim
WORKDIR /app
COPY . .
RUN pip install -e "."
EXPOSE 8080
CMD ["api-bridge", "start", "--host", "0.0.0.0"]apiVersion: apps/v1
kind: Deployment
metadata:
name: api-bridge
spec:
replicas: 3
selector:
matchLabels:
app: api-bridge
template:
metadata:
labels:
app: api-bridge
spec:
containers:
- name: api-bridge
image: api-bridge:latest
ports:
- containerPort: 8080
env:
- name: API_BRIDGE_PORT
value: "8080"[Unit]
Description=API-Bridge Gateway
After=network.target
[Service]
Type=simple
User=api-bridge
WorkingDirectory=/opt/api-bridge
ExecStart=/usr/local/bin/api-bridge start
Restart=always
[Install]
WantedBy=multi-user.targetWe welcome contributions! Please see CONTRIBUTING.md for guidelines.
# Clone repository
git clone https://github.com/gitstq/api-bridge.git
cd api-bridge
# Create virtual environment
python -m venv venv
source venv/bin/activate
# Install dependencies
pip install -e ".[dev]"
# Run tests
pytest
# Run linting
black api_bridge tests
isort api_bridge testsThis project is licensed under the MIT License - see the LICENSE file for details.
- FastAPI - The amazing web framework
- Uvicorn - Lightning-fast ASGI server
- Typer - CLI framework
- Rich - Beautiful terminal output
Made with ❤️ by gitstq