{
  "openapi": "3.1.0",
  "info": {
    "title": "FLOPX GPU spot index API",
    "version": "1.0.0",
    "description": "Read-only API for the FLOPX GPU-hour price index. No authentication. CORS open. Data updates every 5 minutes."
  },
  "servers": [{ "url": "https://flopx.xyz" }],
  "paths": {
    "/v1/index": {
      "get": {
        "summary": "Latest index for every GPU",
        "operationId": "getIndex",
        "responses": {
          "200": { "description": "Latest index", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Index" } } } },
          "503": { "description": "No data collected yet", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }
        }
      }
    },
    "/v1/history/{gpu}": {
      "get": {
        "summary": "Price history for one GPU",
        "operationId": "getHistory",
        "parameters": [
          { "name": "gpu", "in": "path", "required": true, "schema": { "$ref": "#/components/schemas/GpuId" } },
          { "name": "range", "in": "query", "required": false, "schema": { "type": "string", "enum": ["24h", "7d", "30d", "90d"], "default": "7d" }, "description": "24h: raw 5-minute points; 7d: 1-hour buckets; 30d: 4-hour buckets; 90d: 12-hour buckets" }
        ],
        "responses": {
          "200": { "description": "History points", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/History" } } } },
          "400": { "description": "Invalid range", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } },
          "404": { "description": "Unknown GPU id", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }
        }
      }
    },
    "/v1/gpus": {
      "get": {
        "summary": "GPU catalog",
        "operationId": "getGpus",
        "responses": { "200": { "description": "Catalog", "content": { "application/json": { "schema": { "type": "object", "properties": { "headline": { "$ref": "#/components/schemas/GpuId" }, "gpus": { "type": "array", "items": { "$ref": "#/components/schemas/CatalogGpu" } } } } } } } }
      }
    },
    "/health": {
      "get": { "summary": "Liveness", "operationId": "health", "responses": { "200": { "description": "OK", "content": { "application/json": { "schema": { "type": "object", "properties": { "ok": { "type": "boolean" } } } } } } } }
    }
  },
  "components": {
    "schemas": {
      "GpuId": { "type": "string", "enum": ["B300", "B200", "H200", "H200_NVL", "H100_SXM", "H100_PCIE", "H100_NVL", "A100_SXM", "A100_PCIE", "A100_40G", "MI300X", "L40S", "L40", "A40", "RTX_PRO_6000", "RTX6000_ADA", "RTX5090", "RTX4090", "RTX3090"] },
      "CatalogGpu": { "type": "object", "properties": { "id": { "$ref": "#/components/schemas/GpuId" }, "label": { "type": "string" }, "vram": { "type": "integer", "description": "GB" }, "tier": { "type": "string", "enum": ["datacenter", "workstation", "consumer"] } } },
      "Provider": { "type": "object", "properties": { "id": { "type": "string" }, "name": { "type": "string" }, "ok": { "type": "boolean" }, "observations": { "type": "integer" }, "error": { "type": "string" } } },
      "IndexGpu": {
        "type": "object",
        "required": ["gpu", "index", "providers", "offers", "byProvider"],
        "properties": {
          "gpu": { "$ref": "#/components/schemas/GpuId" },
          "label": { "type": "string" },
          "vram": { "type": "integer" },
          "tier": { "type": "string" },
          "index": { "type": "number", "description": "USD per GPU-hour" },
          "min": { "type": "number" },
          "max": { "type": "number" },
          "providers": { "type": "integer" },
          "offers": { "type": "integer" },
          "byProvider": { "type": "object", "additionalProperties": { "type": "number" } },
          "change24h": { "type": ["number", "null"], "description": "Percent change vs about 24h ago" }
        }
      },
      "Index": {
        "type": "object",
        "properties": {
          "updatedAt": { "type": "string", "format": "date-time" },
          "method": { "type": "integer" },
          "headline": { "$ref": "#/components/schemas/GpuId" },
          "providers": { "type": "array", "items": { "$ref": "#/components/schemas/Provider" } },
          "gpus": { "type": "array", "items": { "$ref": "#/components/schemas/IndexGpu" } }
        }
      },
      "History": { "type": "object", "properties": { "gpu": { "$ref": "#/components/schemas/GpuId" }, "range": { "type": "string" }, "points": { "type": "array", "items": { "type": "array", "prefixItems": [{ "type": "integer", "description": "unix ms" }, { "type": "number", "description": "USD per GPU-hour" }] } } } },
      "Error": { "type": "object", "properties": { "error": { "type": "string" } } }
    }
  }
}
