The Cloud Pricing API is an open source GraphQL-based API that includes all public prices from AWS, Azure and Google; it contains over 3 million prices! The prices are automatically updated via a weekly job. You can use our hosted version or self-host (it should take less than 15mins to deploy).
We needed a multi-cloud pricing API that we could use to explore pricing data structures (e.g. what are the various price components for AWS EC2) and filter for specific prices for the Infracost CLI. The cloud vendor pricing APIs do not address these use-cases so we developed and open sourced the Cloud Pricing API, which can also be used independently of the Infracost CLI.
GraphQL is a natural fit for cloud pricing as it can model the JSON structure used by cloud vendors. This enables you to query nested JSON structures using vendor-specific parameters, and request only the attributes you need to be returned in the response. For example, you can find all prices that match AWS EC2 m3.large instance in us-east-1 (over 400 prices), then explore the 30+ attributes that AWS return to describe instances (e.g.
Infracost runs a hosted version of this API that you can use:
- Register for an API key by downloading infracost and running
- Pass the above API key using the
X-Api-Key: xxxxHTTP header when calling https://pricing.api.infracost.io/graphql. The following example fetches the latest price for an AWS EC2 m3.large instance in us-east-1. More examples can be found here.
- Curl request
- GraphQL playground request
The API has two main types: Products and Prices. Each product can have many Prices. This simple high-level schema provides flexibility to model the exact values that the cloud vendor APIs return at the same time as having useful top-level product filters. The values returned by the API are the same ones that the cloud vendors return in their APIs.
The main properties of Products are:
|Name||AWS examples||Microsoft Azure examples||Google Cloud Platform examples|
The main properties of Prices are:
|Price from the cloud vendor in the preferred ISO 4217 currency code (e.g. EUR, BRL or INR). For non-USD currencies, prices are converted from USD to the preferred currency at query time.|
|Unit for the price|
|Any additional description|
|Start usage amount for price tier, only applicable for tiered pricing|
|End usage amount for price tier, only applicable for tiered pricing|
|Purchase option varies between vendors|
|Term of the purchase option|
|Length of the purchase option|
|Offering class or type of the term|
Whilst our main use-case for developing the Cloud Pricing API is the Infracost CLI, we're excited to see what the community does with this API. Please share your use-cases and issues with us on GitHub or Slack or email.