Retrieve Data
Retrieve data from Google Spreadsheets with flexible options. Supports three operation modes: single range retrieval, multiple ranges (batch), and spreadsheet metadata.
Overview
The Retrieve Data tool is a comprehensive solution for reading data from Google Sheets. It supports:
- Three operation modes: Single range, multiple ranges (batch), spreadsheet metadata
- Flexible response formats: Raw arrays, enriched with metadata, or structured objects
- All value render options: Formatted values, unformatted values, or formulas
- Robust validation: Spreadsheet verification, range validation, error handling
Prerequisites
- A connected Google Account with OAuth authentication
- Google Sheets API enabled in your Google Cloud project
- Setup Guide
Parameters
Core Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
spreadsheet_id | string | Yes | Google Spreadsheet ID from URL |
operation_mode | string | Yes | Operation mode: single_range, multiple_ranges, or metadata |
Mode-Specific Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
range | string | Yes* | A1 notation range (*required for single_range mode) |
ranges | array[string] | Yes** | Array of A1 notation ranges (**required for multiple_ranges mode) |
sheet_name | string | No | Default sheet name when range lacks sheet prefix |
Response Format Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
value_render_option | string | FORMATTED_VALUE | How values are rendered: FORMATTED_VALUE, UNFORMATTED_VALUE, or FORMULA |
response_format | string | with_metadata | Response format: raw_array, with_metadata, or objects |
include_empty_rows | boolean | true | Whether to include completely empty rows |
date_time_render_option | string | FORMATTED_STRING | Date/time format: SERIAL_NUMBER or FORMATTED_STRING |
Metadata Mode Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
include_grid_data | boolean | false | For metadata mode: include cell data (makes response larger) |
Usage Examples
Example 1: Basic Single Range (Formatted Values)
Read a simple range with default formatting.
{
"tool": "google_sheets_Retrieve_Data",
"arguments": {
"spreadsheet_id": "1abcDEFgHIjklMNOpQrStUvWxYz",
"operation_mode": "single_range",
"range": "Sheet1!A1:C5"
}
}
Response:
{
"success": true,
"message": "Data retrieved successfully",
"spreadsheet_id": "1abcDEFgHIjklMNOpQrStUvWxYz",
"spreadsheet_url": "https://docs.google.com/spreadsheets/d/...",
"operation": "single_range",
"range": "Sheet1!A1:C5",
"values": [
["Name", "Email", "Status"],
["Alice", "alice@example.com", "Active"],
["Bob", "bob@example.com", "Inactive"]
],
"row_count": 3,
"column_count": 3,
"cell_count": 9,
"value_render_option": "FORMATTED_VALUE"
}
Example 2: Single Range with Unformatted Values
Get raw, unformatted values (useful for numbers, dates).
{
"tool": "google_sheets_Retrieve_Data",
"arguments": {
"spreadsheet_id": "1abcDEFgHIjklMNOpQrStUvWxYz",
"operation_mode": "single_range",
"range": "Sales!A1:C10",
"value_render_option": "UNFORMATTED_VALUE"
}
}
Example 3: Single Range with Formulas
Retrieve formulas instead of calculated values.
{
"tool": "google_sheets_Retrieve_Data",
"arguments": {
"spreadsheet_id": "1abcDEFgHIjklMNOpQrStUvWxYz",
"operation_mode": "single_range",
"range": "Calculations!D1:D10",
"value_render_option": "FORMULA"
}
}
Response will include formulas:
{
"values": [
["Total"],
["=SUM(A1:C1)"],
["=SUM(A2:C2)"]
]
}
Example 4: Multiple Ranges (Batch Read)
Efficiently read multiple non-contiguous ranges in one call.
{
"tool": "google_sheets_Retrieve_Data",
"arguments": {
"spreadsheet_id": "1abcDEFgHIjklMNOpQrStUvWxYz",
"operation_mode": "multiple_ranges",
"ranges": [
"Sales!A1:B5",
"Summary!D1:E3",
"Metrics!G10:H15"
],
"value_render_option": "FORMATTED_VALUE"
}
}
Response:
{
"success": true,
"message": "Data retrieved successfully",
"operation": "multiple_ranges",
"ranges_data": [
{
"range": "Sales!A1:B5",
"values": [["Date", "Amount"], ["2025-01-01", "$1,000"]],
"row_count": 2,
"column_count": 2
},
{
"range": "Summary!D1:E3",
"values": [["Metric", "Value"], ["Total", "$5,000"]],
"row_count": 2,
"column_count": 2
}
],
"total_ranges": 2
}
Example 5: Retrieve Spreadsheet Metadata
Get list of sheets, dimensions, and properties without reading cell data.
{
"tool": "google_sheets_Retrieve_Data",
"arguments": {
"spreadsheet_id": "1abcDEFgHIjklMNOpQrStUvWxYz",
"operation_mode": "metadata"
}
}
Response:
{
"success": true,
"message": "Metadata retrieved successfully",
"operation": "metadata",
"title": "Team Dashboard",
"locale": "en_US",
"timezone": "America/Los_Angeles",
"sheets": [
{
"sheet_id": 0,
"title": "Sales",
"index": 0,
"row_count": 1000,
"column_count": 26,
"frozen_row_count": 1
},
{
"sheet_id": 123456,
"title": "Summary",
"index": 1,
"row_count": 500,
"column_count": 10
}
],
"sheet_count": 2
}
Example 6: Objects Format (Headers as Keys)
Convert rows to objects using first row as keys.
{
"tool": "google_sheets_Retrieve_Data",
"arguments": {
"spreadsheet_id": "1abcDEFgHIjklMNOpQrStUvWxYz",
"operation_mode": "single_range",
"range": "Users!A1:D4",
"response_format": "objects"
}
}
Response:
{
"success": true,
"message": "Data retrieved successfully",
"operation": "single_range",
"range": "Users!A1:D4",
"headers": ["Name", "Email", "Age", "City"],
"data": [
{"Name": "Alice", "Email": "alice@example.com", "Age": "30", "City": "NYC"},
{"Name": "Bob", "Email": "bob@example.com", "Age": "25", "City": "SF"},
{"Name": "Carol", "Email": "carol@example.com", "Age": "35", "City": "LA"}
],
"row_count": 4,
"data_row_count": 3
}
Example 7: Raw Array Format (Simple Output)
Get minimal response with just the 2D array.
{
"tool": "google_sheets_Retrieve_Data",
"arguments": {
"spreadsheet_id": "1abcDEFgHIjklMNOpQrStUvWxYz",
"operation_mode": "single_range",
"range": "Data!A1:B3",
"response_format": "raw_array"
}
}
Response:
{
"success": true,
"message": "Data retrieved successfully",
"values": [
["Header1", "Header2"],
["Value1", "Value2"],
["Value3", "Value4"]
]
}
Example 8: Filter Empty Rows
Exclude completely empty rows from results.
{
"tool": "google_sheets_Retrieve_Data",
"arguments": {
"spreadsheet_id": "1abcDEFgHIjklMNOpQrStUvWxYz",
"operation_mode": "single_range",
"range": "Data!A1:C20",
"include_empty_rows": false
}
}
Example 9: Use Sheet Name Default
Provide range without sheet prefix, use sheet_name parameter.
{
"tool": "google_sheets_Retrieve_Data",
"arguments": {
"spreadsheet_id": "1abcDEFgHIjklMNOpQrStUvWxYz",
"operation_mode": "single_range",
"range": "A1:D10",
"sheet_name": "January 2025"
}
}
Example 10: Date/Time as Serial Numbers
Get dates and times as numeric serial numbers.
{
"tool": "google_sheets_Retrieve_Data",
"arguments": {
"spreadsheet_id": "1abcDEFgHIjklMNOpQrStUvWxYz",
"operation_mode": "single_range",
"range": "Logs!A1:C100",
"date_time_render_option": "SERIAL_NUMBER"
}
}
Example 11: Multiple Ranges with Objects Format
Batch read multiple ranges, each converted to objects.
{
"tool": "google_sheets_Retrieve_Data",
"arguments": {
"spreadsheet_id": "1abcDEFgHIjklMNOpQrStUvWxYz",
"operation_mode": "multiple_ranges",
"ranges": ["Users!A1:C10", "Products!A1:D20"],
"response_format": "objects"
}
}
Example 12: Metadata with Grid Data
Get metadata including actual cell values (large response).
{
"tool": "google_sheets_Retrieve_Data",
"arguments": {
"spreadsheet_id": "1abcDEFgHIjklMNOpQrStUvWxYz",
"operation_mode": "metadata",
"include_grid_data": true
}
}
Operation Modes Explained
Single Range Mode
Purpose: Read data from one specific range
When to use:
- Reading a table of data
- Getting specific cell values
- Extracting a report section
- Reading form responses
Parameters:
- Required:
range(A1 notation) - Optional:
sheet_name(used when range lacks sheet prefix)
Example flow:
- Specify spreadsheet ID and range
- Tool fetches data from Google Sheets API
- Returns data in chosen format
Tip: Include sheet name in range (e.g., Sheet1!A1:D10) or use sheet_name parameter for cleaner code.
Multiple Ranges Mode
Purpose: Read data from multiple non-contiguous ranges in one API call (efficient batch operation)
When to use:
- Reading headers and data separately
- Getting data from multiple sheets
- Extracting scattered data points efficiently
- Combining data from different areas
Parameters:
- Required:
ranges(array of A1 notation ranges) - Optional:
sheet_name(default for ranges without sheet prefix)
Example flow:
- Specify array of ranges
- Tool makes single batch API call
- Returns array of results, one per range
Tip: Much more efficient than multiple single-range calls. Use this when you need data from 2+ locations.
Metadata Mode
Purpose: Get spreadsheet structure and properties without reading cell data
When to use:
- Discovering available sheets before reading
- Validating sheet names exist
- Getting spreadsheet structure info
- Checking dimensions before operations
Returns:
- Spreadsheet title, locale, timezone
- List of all sheets with dimensions
- Sheet IDs, indices, frozen rows/columns
- Optionally: grid data (if
include_grid_data: true)
Example flow:
- Request metadata
- Tool fetches spreadsheet properties
- Returns structured sheet information
Tip: Use this first to discover sheet names, then use single_range or multiple_ranges to read actual data.
Response Format Options
raw_array (Simple)
Returns: Just the 2D array of values
Best for:
- Minimal response size
- When you only need the data
- Piping to other systems
- Simple data extraction
Example:
{
"success": true,
"values": [["A1", "B1"], ["A2", "B2"]]
}
with_metadata (Default, Recommended)
Returns: 2D array plus metadata (range, counts, etc.)
Best for:
- Most use cases (good balance)
- When you need context about the data
- Debugging and verification
- Logging and auditing
Example:
{
"success": true,
"spreadsheet_id": "...",
"spreadsheet_url": "...",
"range": "Sheet1!A1:C5",
"values": [[...]],
"row_count": 5,
"column_count": 3,
"cell_count": 15
}
objects (Structured)
Returns: First row as headers, remaining rows as objects
Best for:
- Working with structured data
- JSON APIs
- When you need key-value pairs
- Database-like access patterns
Example:
{
"success": true,
"headers": ["Name", "Age"],
"data": [
{"Name": "Alice", "Age": "30"},
{"Name": "Bob", "Age": "25"}
]
}
Requirement: First row must contain headers.
Value Render Options
FORMATTED_VALUE (Default)
Returns: Values as they appear in the Google Sheets UI
Best for:
- Most use cases
- When you want human-readable data
- Dates formatted as text
- Currency with symbols ($1,000)
- Percentages (50%)
Example: $1,234.56, 01/15/2025, 50%
UNFORMATTED_VALUE
Returns: Raw underlying values without formatting
Best for:
- Programmatic processing
- Calculations
- Raw numeric values
- Date serial numbers (if not using date_time_render_option)
Example: 1234.56, 45678 (date serial), 0.5 (percentage as decimal)
FORMULA
Returns: Formulas instead of calculated values
Best for:
- Auditing calculations
- Copying formula logic
- Understanding sheet structure
- Debugging formulas
Example: =SUM(A1:A10), =IF(B1>10,"High","Low")
Note: Cells without formulas return their values normally.
Common Use Cases
1. Read Table Data
Scenario: Read a complete data table for processing
Workflow:
- Use
single_rangemode with table range - Use
response_format: "objects"for structured access - Process each row as an object
{
"operation_mode": "single_range",
"range": "Customers!A1:E100",
"response_format": "objects"
}
2. Dashboard Data Collection
Scenario: Collect metrics from multiple sheet locations
Workflow:
- Use
multiple_rangesmode - Specify all metric ranges
- Combine results in your application
{
"operation_mode": "multiple_ranges",
"ranges": [
"Summary!B2",
"Sales!D1:D12",
"Metrics!A5:C5"
]
}
3. Discover Available Sheets
Scenario: List all sheets before reading data
Workflow:
- Use
metadatamode to get sheet list - Parse sheet names
- Use sheet names in subsequent read operations
{
"operation_mode": "metadata"
}
4. Export for Backup
Scenario: Export sheet data for backup/archival
Workflow:
- Use
single_rangewith full sheet range - Use
value_render_option: "UNFORMATTED_VALUE"for raw data - Store in your backup system
5. Form Response Processing
Scenario: Read and process form responses
Workflow:
- Use
single_rangewith response range - Use
response_format: "objects"for easy processing - Filter empty rows with
include_empty_rows: false
6. Data Validation
Scenario: Check if data exists before operation
Workflow:
- Use
single_rangeto read target range - Check if values array is empty
- Proceed with operation or notify user
7. Multi-Sheet Report Aggregation
Scenario: Combine data from multiple sheets
Workflow:
- Use
metadatato discover sheets - Use
multiple_rangesto read from each sheet - Aggregate data in your application
8. Formula Audit
Scenario: Review and document formulas
Workflow:
- Use
value_render_option: "FORMULA" - Read calculation ranges
- Document or analyze formula logic
9. Date-Based Filtering
Scenario: Read data with specific date range
Workflow:
- Use
date_time_render_option: "SERIAL_NUMBER" - Filter by numeric date comparison
- Process matching rows
10. API Data Integration
Scenario: Provide Google Sheets data via API
Workflow:
- Use
response_format: "objects" - Return directly as JSON API response
- Client receives clean key-value data
Troubleshooting
"Spreadsheet not found" Error
Cause: Invalid spreadsheet ID or no access permission
Solutions:
- Verify spreadsheet ID from URL
- Check spreadsheet is shared with your Google account
- Ensure spreadsheet hasn't been deleted
- Confirm OAuth account has access
"Sheet not found" Error
Cause: Sheet name doesn't exist
Solutions:
- Use
metadatamode to list available sheets - Check sheet name spelling (case-sensitive)
- Verify sheet hasn't been renamed or deleted
"Invalid range format" Error
Cause: Range not in valid A1 notation
Solutions:
- Use format:
A1:D10orSheet1!A1:D10 - Don't use row/column numbers (use letters for columns)
- Verify no typos in range syntax
"Google Sheets API is not enabled" Error
Cause: API not activated in Google Cloud project
Solutions:
- Go to Google Cloud Console
- Select your project
- Click "Enable" button
- Wait a moment for activation
- Try again
See: Setup Guide
"Authentication failed" Error
Cause: OAuth token expired or revoked
Solutions:
- Disconnect and reconnect your Google account
- Verify credentials are still active
- Check account hasn't revoked permissions
Empty Response
Cause: Range contains no data or only empty cells
Solutions:
- Verify range actually contains data in Google Sheets
- Check if
include_empty_rows: falseis filtering all rows - Confirm you're reading the correct sheet/range
"Cannot use 'objects' response_format with empty data" Error
Cause: Trying to use objects format with no data
Solutions:
- Ensure range contains at least header row
- Use
with_metadataorraw_arrayformat instead - Verify data exists before using objects format
Best Practices
1. Use Metadata First for Discovery
When working with unfamiliar spreadsheets:
- First call with
metadatamode - Discover available sheets and dimensions
- Then read specific ranges
2. Choose Appropriate Response Format
- objects: For structured data with headers
- with_metadata: For most use cases (good balance)
- raw_array: For minimal responses or piping to other systems
3. Batch Multiple Ranges
Instead of multiple single-range calls:
- Use
multiple_rangesmode - Single API call is faster and more efficient
- Reduces rate limit consumption
4. Filter Empty Rows for Cleaner Data
When reading dynamic ranges:
- Set
include_empty_rows: false - Removes blank rows from response
- Cleaner data for processing
5. Use Appropriate Value Render Option
- FORMATTED_VALUE: For display to users
- UNFORMATTED_VALUE: For calculations
- FORMULA: For auditing/debugging
6. Handle Empty Data Gracefully
Always check if values array is empty:
- Prevents errors in downstream processing
- Provide user-friendly messages
- Validate data exists before operations
7. Specify Sheet Names Explicitly
For maintainability:
- Include sheet name in range:
Sales!A1:C10 - Makes code self-documenting
- Avoids confusion with default sheet
8. Use Descriptive Range Names
Instead of: A1:Z100
Use: DataTable!A1:Z100 with context
9. Test with Small Ranges First
Before reading large datasets:
- Test with small range (e.g., A1:C5)
- Verify format and structure
- Then scale to full range
10. Monitor Response Sizes
For large datasets:
- Consider pagination approach
- Read in chunks if needed
- Balance between API calls and response size
Credits Cost
1 credit per operation (regardless of data size or number of ranges)
Cost is the same for:
- Single range
- Multiple ranges (batch)
- Metadata
Related Tools
- Insert Data - Insert data into sheets (append, replace, new sheet)
- Create Spreadsheet - Create new spreadsheets with initial data
Support
Need help? Check our troubleshooting guide or contact support.