SHEETAI_API Function Guide
Make API calls directly from Google Sheets and extract specific values from responses with AI-powered parsing
What is SHEETAI_API Function?
The SHEETAI_API function enables you to make HTTP API calls directly from Google Sheets. It supports all standard HTTP methods (GET, POST, PUT, PATCH, DELETE), custom headers, request bodies, and intelligent value extraction from API responses using dot notation or array indexing. Perfect for integrating external data sources, automating workflows, and building dynamic spreadsheets.
Basic Syntax
The basic syntax is:
Parameters:
Examples
Simple GET Request
Returns the complete API response
GET with Value Extraction
Extracts only the email field from the response
POST with Headers and Body
Makes a POST request with authentication and extracts the response ID
Array Index Extraction
Extracts the name from the first item in an array
Complex API Call (MagicSlides Example)
Creates an AI-powered presentation with custom settings. Learn more at MagicSlides API Documentation
Key Path Extraction Guide
Use dot notation and array indexing to navigate through API responses:
| Pattern | Description | Example |
|---|---|---|
| data.name | Access nested object property | Gets name from data object |
| items[0] | Access array element by index | Gets first item from array |
| user.posts[2].title | Chain multiple accessors | Gets title of 3rd post |
| response.data.url | Deep nested access | Gets URL from nested structure |
Key Features
- Support for all HTTP methods
- Custom headers and authentication
- Request body for POST/PUT/PATCH
- Smart value extraction with dot notation
- Array indexing support
- Automatic JSON parsing
- Error handling and validation
Common Use Cases
- Fetch data from REST APIs
- Integrate with third-party services
- Automate data collection
- Create dynamic reports
- Send webhooks and notifications
- Build data pipelines
- Generate presentations or documents
Tips for Best Results
- Always validate your URL before making API calls
- Use proper JSON formatting for headers and body (escape quotes with double quotes)
- Test your keyPath with a simple API first to understand the response structure
- Store sensitive API keys in a secure location, not directly in formulas
- Handle API rate limits by spacing out requests
- Use error handling to catch and display API errors gracefully
- Combine with SHEETAI_PJSON for complex response parsing
⚠️ Important Notes
- API calls are subject to Google Apps Script execution time limits
- Always respect API rate limits and terms of service
- Sensitive data in API responses will be visible in your spreadsheet
- Large responses may need to be parsed using SHEETAI_PJSON