{
  "openapi": "3.1.0",
  "info": {
    "title": "SheetJSON",
    "version": "1.0.0",
    "summary": "Read a public Google Sheet as JSON.",
    "description": "Replace docs.google.com with sheetjson.com in a Google Sheets URL. The sheet must be shared as \"Anyone with the link\". No auth. Responses are cached for about 5 minutes.\n\nVersioning: the URL mirrors Google's and is stable. Breaking changes would be announced on https://sheetjson.com with Deprecation and Sunset headers before taking effect."
  },
  "servers": [
    {
      "url": "https://sheetjson.com"
    }
  ],
  "paths": {
    "/spreadsheets/d/{spreadsheetId}": {
      "get": {
        "operationId": "getSheetRows",
        "summary": "Get the rows of a sheet tab",
        "description": "Returns the rows of one tab as an array of objects, keyed by the tab's first row. Empty cells are omitted. Columns without a header are keyed by column letter. A gid that does not exist returns another tab (Google's behavior).",
        "parameters": [
          {
            "$ref": "#/components/parameters/spreadsheetId"
          },
          {
            "$ref": "#/components/parameters/gidQuery"
          }
        ],
        "responses": {
          "200": {
            "description": "Rows of the tab.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Rows"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "413": {
            "$ref": "#/components/responses/Error"
          },
          "502": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/spreadsheets/d/{spreadsheetId}/edit": {
      "get": {
        "operationId": "getSheetRowsFromEditUrl",
        "summary": "Get the rows of a sheet tab, using the URL copied from Google Sheets",
        "description": "Same as getSheetRows. /view and /preview work the same way.",
        "parameters": [
          {
            "$ref": "#/components/parameters/spreadsheetId"
          },
          {
            "$ref": "#/components/parameters/gidQuery"
          }
        ],
        "responses": {
          "200": {
            "description": "Rows of the tab.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Rows"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "413": {
            "$ref": "#/components/responses/Error"
          },
          "502": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/spreadsheets/d/{spreadsheetId}/{gid}": {
      "get": {
        "operationId": "getSheetRowsByGidPath",
        "summary": "Get the rows of a sheet tab, gid in the path",
        "parameters": [
          {
            "$ref": "#/components/parameters/spreadsheetId"
          },
          {
            "name": "gid",
            "in": "path",
            "required": true,
            "description": "Numeric tab id.",
            "schema": {
              "type": "string",
              "pattern": "^\\d{1,12}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Rows of the tab.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Rows"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "413": {
            "$ref": "#/components/responses/Error"
          },
          "502": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    }
  },
  "components": {
    "parameters": {
      "spreadsheetId": {
        "name": "spreadsheetId",
        "in": "path",
        "required": true,
        "description": "The id from the Google Sheets URL (docs.google.com/spreadsheets/d/{spreadsheetId}/...).",
        "schema": {
          "type": "string",
          "pattern": "^[A-Za-z0-9_-]{20,100}$"
        },
        "example": "1olparkGzvli14s-Jn-uVX66vhAf64Fpt78e7pfQPtQ8"
      },
      "gidQuery": {
        "name": "gid",
        "in": "query",
        "required": false,
        "description": "Numeric tab id, from gid= in the sheet URL. Defaults to 0.",
        "schema": {
          "type": "string",
          "pattern": "^\\d{1,12}$",
          "default": "0"
        },
        "example": "1971483596"
      }
    },
    "schemas": {
      "Rows": {
        "type": "array",
        "items": {
          "type": "object",
          "description": "One row. Keys are the tab's column headers.",
          "additionalProperties": {
            "type": [
              "string",
              "number",
              "boolean"
            ]
          }
        }
      },
      "Error": {
        "type": "object",
        "required": [
          "error",
          "code",
          "docs"
        ],
        "properties": {
          "error": {
            "type": "string",
            "description": "Human-readable message."
          },
          "code": {
            "type": "string",
            "enum": [
              "not_public",
              "invalid_url",
              "invalid_gid",
              "too_large",
              "upstream_unavailable",
              "method_not_allowed"
            ]
          },
          "docs": {
            "type": "string",
            "format": "uri",
            "description": "How to fix it."
          }
        }
      }
    },
    "responses": {
      "Error": {
        "description": "Error",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      }
    }
  }
}
