A robust API Gateway application designed to manage and route microservices traffic.
- Microservice management and routing
- Redis-based service registry and discovery
- Rate limiting
- CORS support
- Centralized error handling
- Health checks
- Docker support
- Python 3.9
- FastAPI
- Redis
- Docker & Docker Compose
- HTTPX
- Uvicorn
- Pydantic
Clone and set up the project:
git clone https://github.com/umuttopalak/example-api-gateway.git
cd api-gateway
cp sample.env .env
Start with Docker:
docker-compose up -d
curl -X POST http://localhost:8000/api/services/register \
-H "Content-Type: application/json" \
-d '{"name": "user-service", "url": "http://user-service:8001"}'
GET /api/services
- List all registered servicesPOST /api/services/register
- Register a new serviceDELETE /api/services/{service_name}
- Remove a serviceGET /api/users
- User service endpointsGET /api/products
- Product service endpointsGET /api/orders
- Order service endpoints
Key environment variables:
PORT=8000
REDIS_HOST=redis
REDIS_PORT=6379
RATE_LIMIT=10
RATE_LIMIT_WINDOW=60
- Fork the project
- Create your feature branch (
git checkout -b feature/AmazingFeature
) - Commit your changes (
git commit -m 'Add some AmazingFeature'
) - Push to the branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
Email - [email protected] Project Link: https://github.com/umuttopalak/example-api-gateway