Shipping rate calculator


Frontend: Nextjs form
Backend with Lambda
Working
Your AWS Lambda function will:
Receive the payload from API Gateway
Call 4–5 courier partner APIs concurrently (using
asyncioorThreadPoolExecutor)Return a unified JSON response with rates and delivery times
Example (Python/FastAPI-like Lambda handler):
✅ Fast cold start (Python 3.10/3.11 runtime) ✅ Concurrent API calls → low latency ✅ Serverless → no infra management
API Gateway
API Gateway
Create a REST API in AWS API Gateway.
Connect
/ratesendpoint to the Lambda.Enable CORS so your frontend can call it directly.
Add rate limiting or usage plans (100/day is trivial).
Step 2: Create API Gateway
Go to API Gateway → Create API
Choose “REST API”
Select “Build”
Name:
shipping-rate-apiEndpoint Type: Regional
Create a Resource
Click Actions → Create Resource
Name:
ratesResource Path:
/rates
Create a Method
Under
/rates, click Create Method → POSTIntegration type: Lambda Function
Choose your Lambda:
shipping-rate-calcSave → Allow permission
Enable CORS
Select
/rates → Actions → Enable CORSSet:
Allowed Origins:
*(or restrict to your frontend domain)Allowed Methods:
POSTAllowed Headers:
Content-Type, Authorization
Deploy the API
Actions → Deploy API
Create a new Stage:
prod
You’ll get an endpoint like:
Security
Store courier API keys in AWS Systems Manager Parameter Store or Secrets Manager
Lambda retrieves them securely at runtime:
Last updated
