AWS EC2 Pricing API

Up-to-date API to retrieve available instance types per region and platform, as well as up to date on-demand and spot pricing across every region and availability zones.

The database is updated every hour (about 80k data points).

Fetch available instance types across all regions

Example link: https://ec2-pricing.runs-on.com/instances

Command:

curl -s https://ec2-pricing.runs-on.com/instances | jq '.results'

Results:

{
  "results": [
    {
      "instanceType": "a1.2xlarge",
      "instanceFamily": "a1",
      "vcpus": 8,
      "memoryGiB": 16,
      "gpus": 0,
      "cpuSpeed": 0,
      "regions": [
        "ap-south-1",
        "ap-southeast-1",
        "eu-central-1",
        "eu-west-1",
        "us-east-1",
        "us-east-2",
        "us-west-2"
      ],
      "platforms": [
        "Linux/UNIX"
      ],
      "pricing": {
        "Windows": {
          "avgSpot": 0,
          "avgOnDemand": 0
        },
        "Linux/UNIX": {
          "avgSpot": 0.216,
          "avgOnDemand": 0.216
        }
      },
      "links": {
        "self": "https://ec2-pricing.runs-on.com/instances/a1.2xlarge"
      }
    },
    {
      "instanceType": "a1.4xlarge",
      "instanceFamily": "a1",
      "vcpus": 16,
      "memoryGiB": 32,
      "gpus": 0,
      "cpuSpeed": 0,
      "regions": [
        "ap-northeast-1",
        "ap-south-1",
        "ap-southeast-1",
        "ap-southeast-2",
        "eu-central-1",
        "eu-west-1",
        "us-east-1",
        "us-east-2",
        "us-west-2"
      ],
      "platforms": [
        "Linux/UNIX"
      ],
      "pricing": {
        "Windows": {
          "avgSpot": 0,
          "avgOnDemand": 0
        },
        "Linux/UNIX": {
          "avgSpot": 0.453,
          "avgOnDemand": 0.452
        }
      },
      "links": {
        "self": "https://ec2-pricing.runs-on.com/instances/a1.4xlarge"
      }
    },
    ...
  ]
}

Fetch latest pricing (spot, on-demand) for instance type

Example link: https://ec2-pricing.runs-on.com/instances/c7a.xlarge?az=us-east-1b&platform=Linux/UNIX

Command:

curl -sG https://ec2-pricing.runs-on.com/instances/c7a.xlarge -d az=us-east-1b -d platform=Linux/UNIX | jq .

Result:

{
  "results": [
    {
      "timestamp": "2025-03-27 14:21:12",
      "region": "us-east-1",
      "az": "us-east-1b",
      "instanceFamily": "c7a",
      "instanceType": "c7a.xlarge",
      "platform": "Linux/UNIX",
      "cpuModel": "AMD EPYC 9R14 (x86_64)",
      "vcpus": 4,
      "memoryGiB": 8,
      "gpus": 0,
      "cpuSpeed": 2880,
      "onDemandPrice": 1.70528,
      "spotPrice": 0.103
    }
  ]
}

Can also fetch for an entire family: https://ec2-pricing.runs-on.com/instances/c7a?az=us-east-1b

Filters (query parameters) availables:

Fetch cost for EC2 instance and compare to GitHub runners

Command:

curl -s https://ec2-pricing.runs-on.com/cost -d '{"instanceType": "c7a.xlarge", "region": "us-east-1", "instanceLifecycle": "spot", "startedAt": "2025-03-24T16:50:41+01:00"}' | jq .

Result:

{
  "instanceType": "c7a.xlarge",
  "region": "us-east-1",
  "instanceLifecycle": "spot",
  "vcpus": 4,
  "startedAt": "2025-03-24T16:50:41+01:00",
  "durationMinutes": 1549.11,
  "pricePerHour": 0.10203333333333335,
  "pricePerMinute": 0.002,
  "totalCost": 3.098,
  "github": {
    "pricePerMinutePerVcpu": 0.004,
    "durationMinutes": 1550,
    "totalCost": 24.8
  },
  "savings": {
    "amount": 21.702,
    "percentage": 87.51
  }
}

Rate-limit

Should scale pretty well. This is hosted on CloudFlare workers.

Author