How to Calculate Cost Per API Request Using Costless

One of the most common examples of an AWS serverless architecture is developing APIs for your system or product using API Gateway, Lambda, and DynamoDB.

With AWS Cost Explore, you can see the overall costs of API Gateway, Lambda, and DynamoDB. However, Cost Explore does not calculate the cost per request. This information can be useful in numerous scenarios, such as when you provide an API service with a request-based pricing model.

Below is an example of a customer who uses Costless to determine their API unit price and their budget. By visiting the target resource page from the Costless dashboard, you can see the costs for API Gateway, Lambda, and DynamoDB. We’ll use the information provided to calculate the cost per request.

API Gateway Costs

Lambda Costs

DynamoDB Costs

In this example, you can see the cost for each of the 2,400 requests:

  • API Gateway: $0.01
  • Lambda: $0.008 
  • DynamoDB: $0.0187 

The cost per request of this API can be calculated by adding the costs together and dividing the sum by the total number of requests. 

($0.01 + $0.008 + $0.0187) / 2,400 = $0.00001529

With Costless, it’s possible for the customer to determine their API unit price after calculating the cost per API request.