This project aims to create a GraphQL cloud pricing API. Currently only AWS resources are supported, but future support for other cloud vendors is planned.
This is an early stage project, pull requests to add resources/fix bugs are welcome.
Get all t3.micro prices in US East, this returns 30+ results. Try it yourself by pasting the query into https://pricing.infracost.io/graphql.
query {
products(
filter: {
vendorName: "aws",
service: "AmazonEC2",
productFamily: "Compute Instance",
region: "us-east-1",
attributeFilters: [
{ key: "instanceType", value: "t3.micro" }
]
},
) {
attributes { key, value }
prices { USD }
}
}
Get the hourly on-demand price of a Linux EC2 t3.micro instance in US East:
Request:
query {
products(
filter: {
vendorName: "aws",
service: "AmazonEC2",
productFamily: "Compute Instance",
region: "us-east-1",
attributeFilters: [
{ key: "instanceType", value: "t3.micro" },
{ key: "tenancy", value: "Shared" },
{ key: "operatingSystem", value: "Linux" },
{ key: "capacityStatus", value: "Used" },
{ key: "preInstalledSw", value: "NA" }
]
},
) {
prices(
filter: {
purchaseOption: "on_demand"
},
) { USD }
}
}
Response:
{
"products": [
{
"pricing": [
{
"USD": "0.0104000000"
}
]
}
]
}
- Node.js >= 12.18.0
- MongoDB >= 3.6
- Clone the repo
git clone https://github.com/infracost/cloud-pricing-api.git
cd cloud-pricing-api
- Add a
.env
file to point to your MongoDB server, e.g.
MONGODB_URI=mongodb://localhost:27017/cloudPricing
- Install the npm packages
npm install
- Update the pricing data Note: this downloads about 1.8 GB of data
npm run update
npm start
You can now access the GraphQL Playground at http://localhost:4000/graphql.
- Additional vendors
- A more user-friendly API - this will require adding mappings for all AWS services.
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.