L2 Construct: get_sheet
sheets googleDescription
GetSheet retrieves data from a specific sheet in a Google Sheets spreadsheet. It fetches the content starting from a specified origin point (defaulting to the top-left cell if not provided) and returns it as a Table with headers and rows.
The function requires:
- A valid spreadsheet ID
- The name of the sheet to retrieve
- Optional origin coordinates (row and column) to start data retrieval from
- Optional number of rows to skip from the end of the sheet
It returns the sheet data as a structured Table, along with the spreadsheet ID and sheet name.
L2 Data
- Provider: google
- Module: gsheets
- Action: get_sheet
Example Step
{
"name": "insert-your-step-name",
"type": "l2",
"l2_data": {
"provider": "google",
"module": "gsheets",
"action": "get_sheet",
"metadata": {}
}
}
Input
Example
{
"spreadsheet_id": "1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms",
"sheet_name": "Sheet1",
"origin": {
"row": 0,
"col": 0
}
}
Schema
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://pontus.bpa/pkgs/l2/google/gsheets/get-sheet-input",
"$ref": "#/$defs/GetSheetInput",
"$defs": {
"GetSheetInput": {
"properties": {
"spreadsheet_id": {
"type": "string"
},
"sheet_name": {
"type": "string"
},
"origin": {
"$ref": "#/$defs/Origin"
},
"margin": {
"skip_last_n_rows": {
"type": "integer"
},
"max_empty_rows": {
"type": "integer"
}
}
},
"additionalProperties": false,
"type": "object",
"required": ["spreadsheet_id", "sheet_name"]
},
"Origin": {
"properties": {
"row": {
"type": "integer"
},
"col": {
"type": "integer"
}
},
"additionalProperties": false,
"type": "object",
"required": ["row", "col"]
}
}
}
Output
Example
{
"spreadsheet_id": "1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms",
"sheet_name": "Sheet1",
"table": {
"headers": ["Name", "Age", "City"],
"rows": [["Alice", 30, "New York"], ["Bob", 25, "San Francisco"]]
},
"Error": {
"is_error": false
}
}
Schema
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://pontus.bpa/pkgs/l2/google/gsheets/get-sheet-output",
"$ref": "#/$defs/GetSheetOutput",
"$defs": {
"GetSheetOutput": {
"properties": {
"spreadsheet_id": {
"type": "string"
},
"sheet_name": {
"type": "string"
},
"table": {
"$ref": "#/$defs/Table"
},
"Error": {
"$ref": "#/$defs/HandlerError"
}
},
"additionalProperties": false,
"type": "object",
"required": ["spreadsheet_id", "sheet_name", "table", "Error"]
},
"HandlerError": {
"properties": {
"is_error": {
"type": "boolean"
},
"errors": {
"items": {
"type": "string"
},
"type": "array"
}
},
"additionalProperties": false,
"type": "object",
"required": ["is_error"]
},
"Table": {
"properties": {
"name": {
"type": "string"
},
"description": {
"type": "string"
},
"headers": {
"items": {
"type": "string"
},
"type": "array"
},
"rows": {
"items": {
"items": true,
"type": "array"
},
"type": "array"
}
},
"additionalProperties": false,
"type": "object",
"required": ["headers", "rows"]
}
}
}