clients/client-cost-explorer/README.md
AWS SDK for JavaScript CostExplorer Client for Node.js, Browser and React Native.
<p>You can use the Cost Explorer API 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. This might include the number of daily write operations for Amazon DynamoDB database tables in your production environment. </p> <p>Service Endpoint</p> <p>The Cost Explorer API provides the following endpoint:</p> <ul> <li> <p> <code>https://ce.us-east-1.amazonaws.com</code> </p> </li> </ul> <p>For information about the costs that are associated with the Cost Explorer API, see <a href="http://aws.amazon.com/aws-cost-management/pricing/">Amazon Web Services Cost Management Pricing</a>.</p>To install this package, use the CLI of your favorite package manager:
npm install @aws-sdk/client-cost-exploreryarn add @aws-sdk/client-cost-explorerpnpm add @aws-sdk/client-cost-explorerThe AWS SDK is modulized by clients and commands.
To send a request, you only need to import the CostExplorerClient and
the commands you need, for example ListCostAllocationTagsCommand:
// ES5 example
const { CostExplorerClient, ListCostAllocationTagsCommand } = require("@aws-sdk/client-cost-explorer");
// ES6+ example
import { CostExplorerClient, ListCostAllocationTagsCommand } from "@aws-sdk/client-cost-explorer";
To send a request:
send operation on the client, providing the command object as input.const client = new CostExplorerClient({ region: "REGION" });
const params = { /** input parameters */ };
const command = new ListCostAllocationTagsCommand(params);
We recommend using the await operator to wait for the promise returned by send operation as follows:
// async/await.
try {
const data = await client.send(command);
// process data.
} catch (error) {
// error handling.
} finally {
// finally.
}
You can also use Promise chaining.
client
.send(command)
.then((data) => {
// process data.
})
.catch((error) => {
// error handling.
})
.finally(() => {
// finally.
});
The aggregated client class is exported from the same package, but without the "Client" suffix.
CostExplorer extends CostExplorerClient and additionally supports all operations, waiters, and paginators as methods.
This style may be familiar to you from the AWS SDK for JavaScript v2.
If you are bundling the AWS SDK, we recommend using only the bare-bones client (CostExplorerClient).
More details are in the blog post on
modular packages in AWS SDK for JavaScript.
import { CostExplorer } from "@aws-sdk/client-cost-explorer";
const client = new CostExplorer({ region: "REGION" });
// async/await.
try {
const data = await client.listCostAllocationTags(params);
// process data.
} catch (error) {
// error handling.
}
// Promises.
client
.listCostAllocationTags(params)
.then((data) => {
// process data.
})
.catch((error) => {
// error handling.
});
// callbacks (not recommended).
client.listCostAllocationTags(params, (err, data) => {
// process err and data.
});
When the service returns an exception, the error will include the exception information, as well as response metadata (e.g. request id).
try {
const data = await client.send(command);
// process data.
} catch (error) {
const { requestId, cfId, extendedRequestId } = error.$metadata;
console.log({ requestId, cfId, extendedRequestId });
/**
* The keys within exceptions are also parsed.
* You can access them by specifying exception names:
* if (error.name === 'SomeServiceException') {
* const value = error.specialKeyInException;
* }
*/
}
See also docs/ERROR_HANDLING.
Please use these community resources for getting help. We use GitHub issues for tracking bugs and feature requests, but have limited bandwidth to address them.
aws-sdk-js
on AWS Developer Blog.aws-sdk-js.To test your universal JavaScript code in Node.js, browser and react-native environments, visit our code samples repo.
This client code is generated automatically. Any modifications will be overwritten the next time the @aws-sdk/client-cost-explorer package is updated.
To contribute to client you can check our generate clients scripts.
This SDK is distributed under the Apache License, Version 2.0, see LICENSE for more information.
Command API Reference / Input / Output
</details> <details> <summary> CreateAnomalySubscription </summary>Command API Reference / Input / Output
</details> <details> <summary> CreateCostCategoryDefinition </summary>Command API Reference / Input / Output
</details> <details> <summary> DeleteAnomalyMonitor </summary>Command API Reference / Input / Output
</details> <details> <summary> DeleteAnomalySubscription </summary>Command API Reference / Input / Output
</details> <details> <summary> DeleteCostCategoryDefinition </summary>Command API Reference / Input / Output
</details> <details> <summary> DescribeCostCategoryDefinition </summary>Command API Reference / Input / Output
</details> <details> <summary> GetAnomalies </summary>Command API Reference / Input / Output
</details> <details> <summary> GetAnomalyMonitors </summary>Command API Reference / Input / Output
</details> <details> <summary> GetAnomalySubscriptions </summary>Command API Reference / Input / Output
</details> <details> <summary> GetApproximateUsageRecords </summary>Command API Reference / Input / Output
</details> <details> <summary> GetCommitmentPurchaseAnalysis </summary>Command API Reference / Input / Output
</details> <details> <summary> GetCostAndUsage </summary>Command API Reference / Input / Output
</details> <details> <summary> GetCostAndUsageComparisons </summary>Command API Reference / Input / Output
</details> <details> <summary> GetCostAndUsageWithResources </summary>Command API Reference / Input / Output
</details> <details> <summary> GetCostCategories </summary>Command API Reference / Input / Output
</details> <details> <summary> GetCostComparisonDrivers </summary>Command API Reference / Input / Output
</details> <details> <summary> GetCostForecast </summary>Command API Reference / Input / Output
</details> <details> <summary> GetDimensionValues </summary>Command API Reference / Input / Output
</details> <details> <summary> GetReservationCoverage </summary>Command API Reference / Input / Output
</details> <details> <summary> GetReservationPurchaseRecommendation </summary>Command API Reference / Input / Output
</details> <details> <summary> GetReservationUtilization </summary>Command API Reference / Input / Output
</details> <details> <summary> GetRightsizingRecommendation </summary>Command API Reference / Input / Output
</details> <details> <summary> GetSavingsPlanPurchaseRecommendationDetails </summary>Command API Reference / Input / Output
</details> <details> <summary> GetSavingsPlansCoverage </summary>Command API Reference / Input / Output
</details> <details> <summary> GetSavingsPlansPurchaseRecommendation </summary>Command API Reference / Input / Output
</details> <details> <summary> GetSavingsPlansUtilization </summary>Command API Reference / Input / Output
</details> <details> <summary> GetSavingsPlansUtilizationDetails </summary>Command API Reference / Input / Output
</details> <details> <summary> GetTags </summary>Command API Reference / Input / Output
</details> <details> <summary> GetUsageForecast </summary>Command API Reference / Input / Output
</details> <details> <summary> ListCommitmentPurchaseAnalyses </summary>Command API Reference / Input / Output
</details> <details> <summary> ListCostAllocationTagBackfillHistory </summary>Command API Reference / Input / Output
</details> <details> <summary> ListCostAllocationTags </summary>Command API Reference / Input / Output
</details> <details> <summary> ListCostCategoryDefinitions </summary>Command API Reference / Input / Output
</details> <details> <summary> ListCostCategoryResourceAssociations </summary>Command API Reference / Input / Output
</details> <details> <summary> ListSavingsPlansPurchaseRecommendationGeneration </summary>Command API Reference / Input / Output
</details> <details> <summary> ListTagsForResource </summary>Command API Reference / Input / Output
</details> <details> <summary> ProvideAnomalyFeedback </summary>Command API Reference / Input / Output
</details> <details> <summary> StartCommitmentPurchaseAnalysis </summary>Command API Reference / Input / Output
</details> <details> <summary> StartCostAllocationTagBackfill </summary>Command API Reference / Input / Output
</details> <details> <summary> StartSavingsPlansPurchaseRecommendationGeneration </summary>Command API Reference / Input / Output
</details> <details> <summary> TagResource </summary>Command API Reference / Input / Output
</details> <details> <summary> UntagResource </summary>Command API Reference / Input / Output
</details> <details> <summary> UpdateAnomalyMonitor </summary>Command API Reference / Input / Output
</details> <details> <summary> UpdateAnomalySubscription </summary>Command API Reference / Input / Output
</details> <details> <summary> UpdateCostAllocationTagsStatus </summary> </details> <details> <summary> UpdateCostCategoryDefinition </summary> </details>