GEThttps://api.spotinst.io/aws/costs?accountId={ACCOUNT_ID}&fromDate={FROM_DATE}&toDate={TO_DATE}&aggregationPeriod={AGGREGATION_PERIOD}

Retrieve costs per specified account over a specified time period.

Example of URL with with daily aggregation period over a time period of 30 days:
https://api.spotinst.io/aws/ec2/account/costs?fromDate=1585699200000&toDate=1588291199000&aggregationPeriod=daily

Parameter Type Description
ACCOUNT_ID String

The account from which to retrieve financial information.

Example: act-12345
Default: The default account
FROM_DATE String

Date can be either in ISO-8601 date format (yyyy-mm-dd) or in Unix Timestamp format (e.g. 1494751821472).

Example: 2018-06-20
TO_DATE String

Date can be either in ISO-8601 date format (yyyy-mm-dd) or in Unix Timestamp format (e.g. 1494751821472).

Example: 2018-11-20
AGGREGATION_PERIOD String

Optional. The time period over which data is aggregated. Can only be "daily". For example, the figures in each data set are per day.

Example: daily
Request

Headers
Copied!
Downloaded!
{
   "Content-Type": "application/json",
   "Authorization": "Bearer ${token}"
}
Response - Example 1: Get Costs without Aggregation Period

Headers
Copied!
Downloaded!
{
   "Content-Type": "application/json"
}
Body
Copied!
Downloaded!
{
    "request": {
        "id": "8ce51c56-6971-4783-8e15-b92438f7a65d",
        "url": "/aws/costs",
        "method": "GET",
        "timestamp": "2015-07-06T11:44:27.963Z"
    },
    "response": {
        "status": {
            "code": 200,
            "message": "OK"
        },
        "kind": "spotinst:aws:costs",
        "items": [
{
   "spot": {
       "runningHours": "1470.80",
       "actualCosts": "107.30",
       "potentialCosts": "378.41",
       "savingsPercentage": "71.64"
      }
   }
],             
        "count": 1
    }
}
Response - Example 2: Get Costs with Daily Aggregation Period

Headers
Copied!
Downloaded!
{
   "Content-Type": "application/json"
}
Body
Copied!
Downloaded!
{
  "response": {
    "status": {
      "code": 200,
      "message": "OK"
    },
    "kind": "spotinst:aws:costs",
    "items": [
      {
        "timestamp": "2020-03-06T00:00:00.000Z",
        "spot": {
          "runningHours": "1470.80",
          "actualCosts": "107.30",
          "potentialCosts": "378.41",
          "savingsPercentage": "71.64"
        }
      },
      {
        "timestamp": "2020-03-07T00:00:00.000Z",
        "spot": {
          "runningHours": "1470.80",
          "actualCosts": "107.30",
          "potentialCosts": "378.41",
          "savingsPercentage": "71.64"
        }
      }
    ],
    "count": 1
  }
}