Build a scalable, containerized API management system for real-time sports data using AWS ECS (Fargate), API Gateway, and an external Sports API.
- REST API for real-time sports data.
- Containerized backend powered by Amazon ECS (Fargate).
- Serverless architecture with API Gateway.
- Sports API Key: Sign up at SerpAPI.
- AWS Account: Basic knowledge of ECS, API Gateway, Docker, and Python.
- AWS CLI: Installed and configured.
- SerpAPI Library: Install:
pip install google-search-results
- Docker: CLI and Desktop installed.
git clone https://github.com/ifeanyiro9/containerized-sports-api.git
cd containerized-sports-api
aws ecr create-repository --repository-name sports-api --region us-east-1
aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin <AWS_ACCOUNT_ID>.dkr.ecr.us-east-1.amazonaws.com
docker build --platform linux/amd64 -t sports-api .
docker tag sports-api:latest <AWS_ACCOUNT_ID>.dkr.ecr.us-east-1.amazonaws.com/sports-api:latest
docker push <AWS_ACCOUNT_ID>.dkr.ecr.us-east-1.amazonaws.com/sports-api:latest
- Create a Cluster: Name it
sports-api-cluster
(Fargate launch type). - Task Definition:
- Name:
sports-api-task
- Container:
- Image:
<ECR_URI>
- Port: 8080 (TCP)
- Env Variable:
SPORTS_API_KEY=<YOUR_API_KEY>
- Image:
- Name:
- Service:
- Use Application Load Balancer (ALB).
- Health check path:
/sports
.
Retrieve ALB DNS: sports-api-alb-<AWS_ACCOUNT_ID>.us-east-1.elb.amazonaws.com
- Create a REST API: Name it
Sports API Gateway
. - Resource
/sports
(GET method): Integrate with ALB DNS. - Deploy to stage (e.g.,
prod
).
Access the endpoint:
curl https://<api-gateway-id>.execute-api.us-east-1.amazonaws.com/prod/sports
- Add caching with ElastiCache.
- Store user queries in DynamoDB.
- Secure API Gateway with authentication.
- Automate deployments using CI/CD.