SheetAI

SHEETAI_API Function Guide

Make API calls directly from Google Sheets and extract specific values from responses with AI-powered parsing

Install SheetAI

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:

=SHEETAI_API(url, method, headersJson, bodyJson, keyPath)

Parameters:

url- The API endpoint URL (required)
method- HTTP method: GET, POST, PUT, PATCH, DELETE (defaults to GET)
headersJson- JSON string of headers (optional)
bodyJson- JSON string of request body (optional, for POST/PUT/PATCH)
keyPath- Dot-notation path to extract specific value (optional)

Examples

Simple GET Request

=SHEETAI_API("https://api.example.com/users", "GET", "", "", "")

Returns the complete API response

GET with Value Extraction

=SHEETAI_API("https://api.example.com/user/123", "GET", "", "", "data.email")

Extracts only the email field from the response

POST with Headers and Body

=SHEETAI_API("https://api.example.com/data", "POST", "{\"Authorization\": \"Bearer token123\", \"Content-Type\": \"application/json\"}", "{\"name\": \"John\", \"age\": 30}", "response.id")

Makes a POST request with authentication and extracts the response ID

Array Index Extraction

=SHEETAI_API("https://api.example.com/items", "GET", "", "", "items[0].name")

Extracts the name from the first item in an array

Complex API Call (MagicSlides Example)

=SHEETAI_API("https://api.magicslides.app/public/api/ppt_from_topic", "POST", "", "{\"topic\":\"Artificial Intelligence in Healthcare\",\"extraInfoSource\":\"Focus on recent developments and future prospects\",\"email\":\"pratiksha@indianappguy.com\",\"accessId\":\"3d5412ea-beea-4c35-bf29-788f2d46050b\",\"template\":\"bullet-point1\",\"language\":\"en\",\"slideCount\":10,\"aiImages\":false,\"imageForEachSlide\":true,\"googleImage\":false,\"googleText\":false,\"model\":\"gpt-4\",\"presentationFor\":\"healthcare professionals\",\"watermark\":{\"width\":48,\"height\":48,\"brandURL\":\"https://djgurnpwsdoqjscwqbsj.supabase.co/storage/v1/object/public/watermarks/1712216042174_Sahoo.png\",\"position\":\"BottomRight\"}}", "")

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:

PatternDescriptionExample
data.nameAccess nested object propertyGets name from data object
items[0]Access array element by indexGets first item from array
user.posts[2].titleChain multiple accessorsGets title of 3rd post
response.data.urlDeep nested accessGets 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