{ "version": "2.0", "service": "
The Cost Explorer API allows you to programmatically query your cost and usage data. You can query for aggregated data such as total monthly costs or total daily usage. You can also query for granular data, such as the number of daily write operations for DynamoDB database tables in your production environment.
Service Endpoint
The Cost Explorer API provides the following endpoint:
https://ce.us-east-1.amazonaws.com
Retrieve cost and usage metrics for your account. You can specify which cost and usage-related metric, such as BlendedCosts
or UsageQuantity
, that you want the request to return. You can also filter and group your data by various dimensions, such as AWS Service
or AvailabilityZone
, in a specific time range. See the GetDimensionValues
action for a complete list of the valid dimensions. Master accounts in an organization have access to all member accounts.
You can use GetDimensionValues
to retrieve all available filter values for a specific filter over a period of time. You can search the dimension values for an arbitrary string.
You can retrieve the Reservation utilization for your account. Master accounts in an organization have access to their associated member accounts. You can filter data by dimensions in a time period. You can use GetDimensionValues
to determine the possible dimension values. Currently, you can group only by SUBSCRIPTION_ID
.
You can query for available tag keys and tag values for a specified period. You can search the tag values for an arbitrary string.
" }, "shapes": { "AttributeType": { "base": null, "refs": { "Attributes$key": null } }, "AttributeValue": { "base": null, "refs": { "Attributes$value": null } }, "Attributes": { "base": null, "refs": { "DimensionValuesWithAttributes$Attributes": "The attribute that applies to a specific Dimension
.
The attributes for this group of RIs.
" } }, "Context": { "base": null, "refs": { "GetDimensionValuesRequest$Context": "The context for the call to GetDimensionValues
. This can be RESERVED_INSTANCE
or COST_AND_USAGE
. The default value is COST_AND_USAGE
. If the context is set to RESERVED_INSTANCE
, the resulting dimension values can be used in the GetReservationUtilization
action. If the context is set to COST_AND_USAGE
, , the resulting dimension values can be used in the GetCostAndUsage
operation.
If you set the context to CostAndUsage
, you can use the following dimensions for searching:
AZ - The Availability Zone. An example is us-east-1a.
InstanceType - The type of EC2 instance. An example is m4.xlarge.
LinkedAccount - The description in the attribute map that includes the full name of the member account. The value field contains the AWS ID of the member account
Operation - The action performed. Examples include RunInstance and CreateBucket.
PurchaseType - The reservation type of the purchase to which this usage is related. Examples include: On Demand Instances and Standard Reserved Instances
Service - The AWS service such as DynamoDB.
UsageType -The type of usage. An example is DataTransfer-In-Bytes. The response for the GetDimensionValues action includes a unit attribute, examples of which include GB and Hrs.
UsageTypeGroup - The grouping of common usage types. An example is EC2: CloudWatch – Alarms. The response for this action includes a unit attribute.
RecordType - The different types of charges such as RI fees, usage costs, tax refunds, and credits
If you set the context to ReservedInstance
, you can use the following dimensions for searching:
AZ - The Availability Zone. An example is us-east-1a.
InstanceType - The type of EC2 instance. An example is m4.xlarge.
LinkedAccount - The description in the attribute map that includes the full name of the member account. The value field contains the AWS ID of the member account
Platform - The operating system. Examples are Windows or Linux.
Region - The AWS region.
Scope - The scope of a reserved instance (RI). Values are regional or a single availability zone.
Tenancy - The tenancy of a resource. Examples are shared or dedicated.
The time period that you want the usage and costs for.
", "refs": { "GetCostAndUsageRequest$TimePeriod": "Sets the start and end dates for retrieving AWS costs. The start date is inclusive, but the end date is exclusive. For example, if start
is 2017-01-01
and end
is 2017-05-01
, then the cost and usage data is retrieved from 2017-01-01
up to and including 2017-04-30
but not including 2017-05-01
.
The start and end dates for retrieving the dimension values. The start date is inclusive, but the end date is exclusive. For example, if start
is 2017-01-01
and end
is 2017-05-01
, then the cost and usage data is retrieved from 2017-01-01
up to and including 2017-04-30
but not including 2017-05-01
.
Sets the start and end dates for retrieving reserve instance (RI) utilization. The start date is inclusive, but the end date is exclusive. For example, if start
is 2017-01-01
and end
is 2017-05-01
, then the cost and usage data is retrieved from 2017-01-01
up to and including 2017-04-30
but not including 2017-05-01
.
The start and end dates for retrieving the dimension values. The start date is inclusive, but the end date is exclusive. For example, if start
is 2017-01-01
and end
is 2017-05-01
, then the cost and usage data is retrieved from 2017-01-01
up to and including 2017-04-30
but not including 2017-05-01
.
The time period covered by a result.
", "UtilizationByTime$TimePeriod": "The period of time over which this utilization was used.
" } }, "Dimension": { "base": null, "refs": { "DimensionValues$Key": "The names of the metadata types that you can use to filter and group your results. For example, AZ
returns a list of Availability Zones.
The name of the dimension. Different Dimensions
are available for different Context
s. For more information, see Context
.
The metadata that you can use to filter and group your results. You can use GetDimensionValues
to find specific values.
The specific Dimension
to use for Expression
.
The metadata of a specific type that you can use to filter and group your results. You can use GetDimensionValues
to find specific values.
The filters that you used to filter your request. Some dimensions are available only for a specific context:
If you set the context to CostAndUsage
, you can use the following dimensions for searching:
AZ - The Availability Zone. An example is us-east-1a.
InstanceType - The type of EC2 instance. An example is m4.xlarge.
LinkedAccount - The description in the attribute map that includes the full name of the member account. The value field contains the AWS ID of the member account
Operation - The action performed. Examples include RunInstance and CreateBucket.
PurchaseType - The reservation type of the purchase to which this usage is related. Examples include: On Demand Instances and Standard Reserved Instances
Service - The AWS service such as DynamoDB.
UsageType -The type of usage. An example is DataTransfer-In-Bytes. The response for the GetDimensionValues action includes a unit attribute, examples of which include GB and Hrs.
UsageTypeGroup - The grouping of common usage types. An example is EC2: CloudWatch – Alarms. The response for this action includes a unit attribute.
RecordType - The different types of charges such as RI fees, usage costs, tax refunds, and credits
If you set the context to ReservedInstance
, you can use the following dimensions for searching:
AZ - The Availability Zone. An example is us-east-1a.
InstanceType - The type of EC2 instance. An example is m4.xlarge.
LinkedAccount - The description in the attribute map that includes the full name of the member account. The value field contains the AWS ID of the member account
Platform - The operating system. Examples are Windows or Linux.
Region - The AWS region.
Scope - The scope of a reserved instance (RI). Values are regional or a single availability zone.
Tenancy - The tenancy of a resource. Examples are shared or dedicated.
Whether or not this result is estimated.
" } }, "Expression": { "base": "Use Expression
to filter by cost or by usage. There are two patterns:
Simple dimension values - You can set the dimension name and values for the filters that you plan to use. For example, you can filter for InstanceType==m4.xlarge OR InstanceType==c4.large
. The Expression
for that looks like this.
{ \"Dimensions\": { \"Key\": \"InstanceType\", \"Values\": [ \"m4.xlarge\", “c4.large” ] } }
The list of dimension values are OR'd together to retrieve cost or usage data. You can create Expression
and DimensionValues
objects using either with*
methods or set*
methods in multiple lines.
Compound dimension values with logical operations - You can use multiple Expression
types and the logical operators AND/OR/NOT
to create a list of one or more Expression
objects. This allows you to filter on more advanced options. For example, you can filter on ((InstanceType == m4.large OR InstanceType == m3.large) OR (Tag.Type == Type1)) AND (UsageType != DataTransfer)
. The Expression
for that looks like this.
{ \"And\": [ {\"Or\": [ {\"Dimensions\": { \"Key\": \"InstanceType\", \"Values\": [ \"m4.x.large\", \"c4.large\" ] }}, {\"Tag\": { \"Key\": \"TagName\", \"Values\": [\"Value1\"] } } ]}, {\"Not\": {\"dimensions\": { \"Key\": \"UsageType\", \"Values\": [\"DataTransfer\"] }}} ] }
Because each Expression
can have only one operator, the service returns an error if more than one is specified. The following example shows an Expression object that will create an error.
{ \"And\": [ ... ], \"DimensionValues\": { \"Dimension\": \"UsageType\", \"Values\": [ \"DataTransfer\" ] } }
Return results that don't match Dimension
.
Filters AWS costs by different dimensions. For example, you can specify Service
and Linked Account
and get the costs associated with that account's usage of that service. You can nest Expression
objects to define any combination of dimension filters. For more information, see the Expression
object or More Examples
.
Filters utilization data by using different dimensions. GetReservationUtilization
uses the same Expression
object as the other operations, but only AND
is supported among each dimension, and nesting is supported up to only one level deep. If there are multiple values for a dimension, they are OR'd together.
Return results that match either Dimension
.
Return results that match both Dimension
objects.
Sets the AWS cost granularity to MONTHLY
or DAILY
.
Sets the AWS cost granularity to MONTHLY
or DAILY
. If both GroupBy
and granularity
are not set, GetReservationUtilization
defaults to DAILY
. If GroupBy
is set, Granularity
can't be set, and the response object doesn't include MONTHLY
or DAILY
granularity.
One level of grouped data within the results.
", "refs": { "Groups$member": null } }, "GroupDefinition": { "base": "Represents a group when you specify a group by criteria, or in the response to a query with a specific grouping.
", "refs": { "GroupDefinitions$member": null } }, "GroupDefinitionKey": { "base": null, "refs": { "GroupDefinition$Key": "The string that represents a key for a specified group.
" } }, "GroupDefinitionType": { "base": null, "refs": { "GroupDefinition$Type": "The string that represents the type of group.
" } }, "GroupDefinitions": { "base": null, "refs": { "GetCostAndUsageRequest$GroupBy": "You can group AWS costs using up to two different groups, either dimensions, tag keys, or both.
When you group by tag key, you get all tag values, including empty strings.
Valid values are: AZ
, INSTANCE_TYPE
, LINKED_ACCCOUNT
, OPERATION
, PURCHASE_TYPE
, SERVICE
, USAGE_TYPE
, TAGS
, and PLATFORM
.
The groups specified by the the Filter
or GroupBy
parameters in the request.
Groups only by SubscriptionId
. Metadata is included.
The groups that are included in this time period.
" } }, "Key": { "base": null, "refs": { "Keys$member": null } }, "Keys": { "base": null, "refs": { "Group$Keys": "The keys included in this group.
" } }, "LimitExceededException": { "base": "You made too many calls in a short period of time. Try again later.
", "refs": { } }, "MetricAmount": { "base": null, "refs": { "MetricValue$Amount": "The actual number that represents the metric.
" } }, "MetricName": { "base": null, "refs": { "MetricNames$member": null, "Metrics$key": null } }, "MetricNames": { "base": null, "refs": { "GetCostAndUsageRequest$Metrics": "Which metrics are returned in the query. For more information about blended and unblended rates, see https://aws.amazon.com/premiumsupport/knowledge-center/blended-rates-intro/.
Valid values are BlendedCost
, UnblendedCost
, and UsageQuantity
.
If you return the UsageQuantity
metric, the service aggregates all usage numbers without taking into account the units. For example, if you aggregate usageQuantity
across all of EC2, the results aren't meaningful because EC2 compute hours and data transfer are measured in different units (for example, hours vs. GB). To get more meaningful UsageQuantity
metrics, filter by UsageType
or UsageTypeGroups
.
The unit that the metric is given in.
" } }, "MetricValue": { "base": "The aggregated value for a metric.
", "refs": { "Metrics$value": null } }, "Metrics": { "base": null, "refs": { "Group$Metrics": "The metrics included in this group.
", "ResultByTime$Total": "The total amount of cost or usage accrued during the time period.
" } }, "NextPageToken": { "base": null, "refs": { "GetCostAndUsageRequest$NextPageToken": "The token to retrieve the next set of results. AWS provides the token when the response from a previous call has more results than the maximum page size.
", "GetCostAndUsageResponse$NextPageToken": "The token for the next set of retrievable results. AWS provides the token when the response from a previous call has more results than the maximum page size.
", "GetDimensionValuesRequest$NextPageToken": "The token to retrieve the next set of results. AWS provides the token when the response from a previous call has more results than the maximum page size.
", "GetDimensionValuesResponse$NextPageToken": "The token for the next set of retrievable results. AWS provides the token when the response from a previous call has more results than the maximum page size.
", "GetReservationUtilizationRequest$NextPageToken": "The token to retrieve the next set of results. AWS provides the token when the response from a previous call has more results than the maximum page size.
", "GetReservationUtilizationResponse$NextPageToken": "The token for the next set of retrievable results. AWS provides the token when the response from a previous call has more results than the maximum page size.
", "GetTagsRequest$NextPageToken": "The token to retrieve the next set of results. AWS provides the token when the response from a previous call has more results than the maximum page size.
", "GetTagsResponse$NextPageToken": "The token for the next set of retrievable results. AWS provides the token when the response from a previous call has more results than the maximum page size.
" } }, "PageSize": { "base": null, "refs": { "GetDimensionValuesResponse$ReturnSize": "The number of results that AWS returned at one time.
", "GetDimensionValuesResponse$TotalSize": "The total number of search results.
", "GetTagsResponse$ReturnSize": "The number of query results that AWS returns at a time.
", "GetTagsResponse$TotalSize": "The total number of query results.
" } }, "PurchasedHours": { "base": null, "refs": { "ReservationAggregates$PurchasedHours": "How many RI hours you purchased.
" } }, "ReservationAggregates": { "base": "The aggregated numbers for your RI usage.
", "refs": { "GetReservationUtilizationResponse$Total": "The total amount of time that you utilized your RIs.
", "ReservationUtilizationGroup$Utilization": "How much you used this group of RIs.
", "UtilizationByTime$Total": "The total number of RI hours that were used.
" } }, "ReservationGroupKey": { "base": null, "refs": { "ReservationUtilizationGroup$Key": "The key for a specific RI attribute.
" } }, "ReservationGroupValue": { "base": null, "refs": { "ReservationUtilizationGroup$Value": "The value of a specific RI attribute.
" } }, "ReservationUtilizationGroup": { "base": "A group of RIs that share a set of attributes.
", "refs": { "ReservationUtilizationGroups$member": null } }, "ReservationUtilizationGroups": { "base": null, "refs": { "UtilizationByTime$Groups": "The groups that are included in this utilization result.
" } }, "ResultByTime": { "base": "The result that is associated with a time period.
", "refs": { "ResultsByTime$member": null } }, "ResultsByTime": { "base": null, "refs": { "GetCostAndUsageResponse$ResultsByTime": "The time period covered by the results in the response.
" } }, "SearchString": { "base": null, "refs": { "GetDimensionValuesRequest$SearchString": "The value that you want to search the filter values for.
", "GetTagsRequest$SearchString": "The value that you want to search for.
" } }, "TagKey": { "base": null, "refs": { "GetTagsRequest$TagKey": "The key of the tag that you want to return values for.
", "TagValues$Key": "The key for a tag.
" } }, "TagList": { "base": null, "refs": { "GetTagsResponse$Tags": "The tags that match your request.
" } }, "TagValues": { "base": "The values that are available for a tag.
", "refs": { "Expression$Tags": "The specific Tag
to use for Expression
.
The total number of RI hours that you used.
" } }, "UnusedHours": { "base": null, "refs": { "ReservationAggregates$UnusedHours": "The number of RI hours that you didn't use.
" } }, "UtilizationByTime": { "base": "The amount of utilization, in hours.
", "refs": { "UtilizationsByTime$member": null } }, "UtilizationPercentage": { "base": null, "refs": { "ReservationAggregates$UtilizationPercentage": "The percentage of RI time that you used.
" } }, "UtilizationsByTime": { "base": null, "refs": { "GetReservationUtilizationResponse$UtilizationsByTime": "The amount of time that you utilized your RIs.
" } }, "Value": { "base": null, "refs": { "DimensionValuesWithAttributes$Value": "The value of a dimension with a specific attribute.
", "Values$member": null } }, "Values": { "base": null, "refs": { "DimensionValues$Values": "The metadata values that you can use to filter and group your results. You can use GetDimensionValues
to find specific values.
The specific value of a tag.
" } }, "YearMonthDay": { "base": null, "refs": { "DateInterval$Start": "The beginning of the time period that you want the usage and costs for. The start date is inclusive. For example, if start
is 2017-01-01
, then the cost and usage data is retrieved starting at 2017-01-01
up to the end date.
The end of the time period that you want the usage and costs for. The end date is exclusive. For example, if the end
is 2017-05-01
, then the cost and usage data is retrieved from the start date but not including 2017-05-01
.