- Go to Serpapi website and register, confirm registartion.
- Confirm registration in email and verify phone number.
- Click "Verify phone number" and enter your phone number.
- Enter verification number sent to your phone. You will be notified a successfull confirmation.
2. Must have an AWS Account & have basic understanding of ECS, API Gateway, Docker & Python.
- Verfiy if you have AWS CLI installed using the "version" command
- If AWS CLI is not installed, you will not see any output. Use the "Pip install" command to install AWS CLI.
pip install aws cli-
Configure AWS
- The information needed can be found in your AWS account, you may need to create a Secret Access Key if you don't already have one. Input "json" for your format.
aws configure3. Install Serpapi library in local environment.
pip install google-search-results4. Docker CLI and Desktop Installed: To build & push container images.
- Verify Docker is installed. If docker is not installed, no output will be returned.
docker --version
``
- If not output was returnted, Docker is not installed. Enter these commands below to install.
- First, update system to ensure everything is up to date.
```bash
sudo apt-get update- Install Docker.
sudo apt install docker.io- Enable Docker.
sudo systemctl enable docker- Verify Docker is enabled.
systemctl status docker- Start Docker, enter password.
systemctl start docker-
Run Docker to verify everthing is working correctly. A message will display it's working coreclty if it's functioning correctly.
sudo docker run hello-world
git clone https://github.com/MJaloui/Containerized-Sports-API.git
cd containerized-sports-apiaws ecr create-repository --repository-name sports-api --region us-east-1- Verify the repository was created in "Amazon ECR > Private registry > Repositories".
aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin <AWS_ACCOUNT_ID>.dkr.ecr.us-east-1.amazonaws.comsudo 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:sports-api-latestdocker push <AWS_ACCOUNT_ID>.dkr.ecr.us-east-1.amazonaws.com/sports-api:sports-api-latest- Verify the image was created, go to Elastic Container Registry > Images > Sports-API.
- Create an ECS Cluster:
- Go to the ECS Console → Clusters → Create Cluster
- Name your Cluster (sports-api-cluster)
- For Infrastructure, select Fargate, then create Cluster. It it was succesfull, a green successfull banner will be displayed.
- Go to Task Definitions → Create New Task Definition.
- Name your task definition (sports-api-task)
- For Infrastructure, select "Fargate", leave everything else at default and click "Create".
-
Add the container:
- Name your container (sports-api-container)
- Image URI: <AWS_ACCOUNT_ID>.dkr.ecr.us-east-1.amazonaws.com/sports-api:sports-api-latest
- Container Port: 8080
- Protocol: TCP
- Port Name: Leave Blank
- App Protocol: HTTP
- Add Environment Variables:
- Key name: SPORTS_API_KEY
- Value: <YOUR_SPORTSDATA.IO_API_KEY>
- Create task definition
- Verify creation is successful, look for green banner display.
- If you scroll down to "Container name" you can see the image.
- Go to Clusters → Select Cluster → Service → Create.
- Capacity provider: Fargate
- Select Deployment configuration family (sports-api-task)
- Name your service (sports-api-service)
- Desired tasks: 2
- Networking: Create new security group
- Networking Configuration:
- Type: All TCP
- Source: Anywhere
- Load Balancing: Select "Use load Balancing" and "Application load Balancer (ALB)"
-
ALB Configuration:
-
Create a new ALB:
-
Name: sports-api-alb
- Target Group health check path: "/sports"
- Create service
-
Verify successful creation, a green banner will be displayed. This may take a few minutes to appear.
- After deploying the ECS service, note the DNS name of the ALB (e.g., sports-api-alb-<AWS_ACCOUNT_ID>.us-east-1.elb.amazonaws.com)
- Confirm the API is accessible by visiting the ALB DNS name in your browser and adding /sports at end (e.g, http://sports-api-alb-<AWS_ACCOUNT_ID>.us-east-1.elb.amazonaws.com/sports). Select "Pretty print" to display readable text
- Create a New REST API:
- Go to API Gateway Console and scroll down → Build API
- Name the API (e.g., Sports API Gateway), then click create.
- Verify successful creation, a green banner will be displayed.
- Set Up Integration (create a resource):
-
Click "Create resource"
-
Create the resource "/sports", (Resource path = /) (Resource name = sports).
-
Click "Create resource".
-
Verify successful creation, a green banner will be displayed along with the resource "/sports".
- Create a GET method
- Choose HTTP Proxy as the integration type, Method type = Get, Integration type = HTTP, HTTP proxy integration should be on.
-
Select "GET" for HTTP method.
-
Enter the DNS name of the ALB that includes "/sports" (e.g. http://sports-api-<AWS_ACCOUNT_ID>.us-east-1.elb.amazonaws.com/sports).
-
Create Method.
-
Verify successful banner
- Deploy the API:
- Deploy the API, Select "New stage" for Stage and enter "Dev" for stage name.
- Verify Successful creation, a green banner will be displayed.
- Copy the endpoint URL.
-
Use curl or a browser to test(I tested on the browser):
-
Enter the command below if you'd like to test it in the command line instead.
curl https://<api-gateway-id>.execute-api.us-east-1.amazonaws.com/prod/sports- Select "Petty-print" to view data in a readable text.



























































































