{
  "openapi": "3.1.0",
  "info": {
    "title": "BigQuery Cost Check API",
    "version": "2026-11-07",
    "description": "The BigQuery Cost Check as an API: the same engine as the page. Send query results for one location, get a report. Results are reported on in memory and dropped with the response. Nothing is stored or logged."
  },
  "servers": [
    {
      "url": "https://tools.finitizer.com"
    }
  ],
  "paths": {
    "/bigquery-cost-check/api": {
      "post": {
        "operationId": "runCostCheck",
        "summary": "Report on BigQuery query results for one location.",
        "parameters": [
          {
            "name": "format",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "json",
                "markdown"
              ]
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "location",
                  "results"
                ],
                "properties": {
                  "location": {
                    "type": "string",
                    "description": "A BigQuery location id, such as us, eu or us-central1. A location stated inside a result wins."
                  },
                  "scope": {
                    "type": "string",
                    "enum": [
                      "project",
                      "organization"
                    ],
                    "default": "project"
                  },
                  "results": {
                    "type": "object",
                    "additionalProperties": false,
                    "description": "Any of the four results. A missing result is reported as not provided, never as zero.",
                    "properties": {
                      "compute": {
                        "oneOf": [
                          {
                            "type": "string",
                            "description": "The result as text."
                          },
                          {
                            "type": "object",
                            "properties": {
                              "text": {
                                "type": "string"
                              }
                            },
                            "required": [
                              "text"
                            ]
                          },
                          {
                            "type": "object",
                            "properties": {
                              "base64": {
                                "type": "string",
                                "description": "The result, base64 encoded. Use this if a firewall refuses the text."
                              }
                            },
                            "required": [
                              "base64"
                            ]
                          }
                        ]
                      },
                      "patterns": {
                        "oneOf": [
                          {
                            "type": "string",
                            "description": "The result as text."
                          },
                          {
                            "type": "object",
                            "properties": {
                              "text": {
                                "type": "string"
                              }
                            },
                            "required": [
                              "text"
                            ]
                          },
                          {
                            "type": "object",
                            "properties": {
                              "base64": {
                                "type": "string",
                                "description": "The result, base64 encoded. Use this if a firewall refuses the text."
                              }
                            },
                            "required": [
                              "base64"
                            ]
                          }
                        ]
                      },
                      "storage": {
                        "oneOf": [
                          {
                            "type": "string",
                            "description": "The result as text."
                          },
                          {
                            "type": "object",
                            "properties": {
                              "text": {
                                "type": "string"
                              }
                            },
                            "required": [
                              "text"
                            ]
                          },
                          {
                            "type": "object",
                            "properties": {
                              "base64": {
                                "type": "string",
                                "description": "The result, base64 encoded. Use this if a firewall refuses the text."
                              }
                            },
                            "required": [
                              "base64"
                            ]
                          }
                        ]
                      },
                      "capacity": {
                        "oneOf": [
                          {
                            "type": "string",
                            "description": "The result as text."
                          },
                          {
                            "type": "object",
                            "properties": {
                              "text": {
                                "type": "string"
                              }
                            },
                            "required": [
                              "text"
                            ]
                          },
                          {
                            "type": "object",
                            "properties": {
                              "base64": {
                                "type": "string",
                                "description": "The result, base64 encoded. Use this if a firewall refuses the text."
                              }
                            },
                            "required": [
                              "base64"
                            ]
                          }
                        ]
                      }
                    }
                  },
                  "storageRates": {
                    "type": "object",
                    "description": "Your own storage rates, in dollars per GiB-month.",
                    "required": [
                      "activeLogical",
                      "longTermLogical",
                      "activePhysical",
                      "longTermPhysical"
                    ],
                    "properties": {
                      "activeLogical": {
                        "type": "number",
                        "minimum": 0
                      },
                      "longTermLogical": {
                        "type": "number",
                        "minimum": 0
                      },
                      "activePhysical": {
                        "type": "number",
                        "minimum": 0
                      },
                      "longTermPhysical": {
                        "type": "number",
                        "minimum": 0
                      }
                    }
                  },
                  "format": {
                    "type": "string",
                    "enum": [
                      "json",
                      "markdown"
                    ],
                    "default": "json"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The report. Fields are described in data.json."
          },
          "400": {
            "description": "The request is not valid."
          },
          "413": {
            "description": "Over 5000000 bytes."
          },
          "422": {
            "description": "No result could be read, or the results disagree on location or scope."
          },
          "429": {
            "description": "Over 20 reports a minute."
          }
        }
      }
    }
  }
}
