Using the /ai endpoint
API Spreadsheets Team ·
What is the AI Endpoint?
The /ai endpoint lets you perform natural-language CRUD on any spreadsheet: just describe what you want in plain English, and the API will read, create, update, or delete rows for you.
Prerequisites
- API Spreadsheets account
- Account-level API keys (
access_keyandsecret_key) - A spreadsheet uploaded to your account (to get a
file_idandfile access keyandfile secret key)
Where to find your account keys

Where to find your File ID and File Keys

Python Setup
# $ pip install apispreadsheets
from apispreadsheets_lib import APISpreadsheets
account_access_key = "YOUR_ACCOUNT_ACCESS_KEY"
account_secret_key = "YOUR_ACCOUNT_SECRET_KEY"
file_id = "YOUR_FILE_ID"
file_access_key = "YOUR_FILE_ACCESS_KEY"
file_secret_key = "YOUR_FILE_SECRET_KEY"
api = APISpreadsheets(access_key=account_access_key, secret_key=account_secret_key)Starting Spreadsheet (preview)
Here’s a trimmed view of your sheet (we’ll work with the first 5 rows and the most relevant columns):
Before any AI actions
| Name | Vibe | Price | Dishes | Address | Cuisine | URL |
|---|---|---|---|---|---|---|
| Medan Pesar | Casual | $$ | Beef rendang, BBQ Stingray | 102 E 7th St, New York, NY 10009 | Malaysian | http://medanpasar.com/ |
| Prince Street Pizza | Grab and go | $ | Square pepperoni slice | 27 Prince St A, New York, NY 10012 | Italian, Pizza | https://princestreetpizzanyc.com/ |
| Rubirosa | Nice Casual | $$ | Vodka pie | 235 Mulberry St, New York, NY 10012 | Italian, Pizza | https://www.rubirosanyc.com/ |
| Wah Fung Fast Food | Grab and go | $ | Roast pork & chicken with rice | 79 Chrystie St, New York, NY 10002 | Chinese, Cantonese BBQ | https://www.yelp.com/biz/wah-fung-no-1-new-york-2 |
| Thai Diner | Nice Casual | $$ | Khao Soi, Larb | 186 Mott St, New York, NY 10012 | Thai | https://www.thaidiner.com/ |
Added rowUpdated cellDeleted rowThis is an illustrative snapshot.
Create: add a new restaurant row
We’ll add Mekelburg’s with a short natural-language prompt. The AI will infer columns from your data and insert a new row.
create_prompt = (
"I found a new restaurant to add to the list. It's called Mekelburg's "
"with a Casual Fun vibe. It's a classic Jewish deli reimagined and is "
"moderately priced. Their must get dishes are their matzo ball soup and wings. "
"The address is 319 Kent Ave, Brooklyn, NY 11249, United States with Latitude 40.7137358 "
"and Longitude -73.9900738. This is the Yelp URL https://www.yelp.com/biz/mekelburgs-brooklyn-3 "
"and I found this restaurant from the Infatuation website with article at this URL "
"https://www.theinfatuation.com/new-york/reviews/mekelburgs-williamsburg"
)
create_ok = api.ai(
file_id=file_id,
prompt=create_prompt,
access_key=file_access_key,
secret_key=file_secret_key
)After CREATE — new row added
| Name | Vibe | Price | Dishes | Address | Cuisine | URL |
|---|---|---|---|---|---|---|
| Medan Pesar | Casual | $$ | Beef rendang, BBQ Stingray | 102 E 7th St, New York, NY 10009 | Malaysian | http://medanpasar.com/ |
| Prince Street Pizza | Grab and go | $ | Square pepperoni slice | 27 Prince St A, New York, NY 10012 | Italian, Pizza | https://princestreetpizzanyc.com/ |
| Rubirosa | Nice Casual | $$ | Vodka pie | 235 Mulberry St, New York, NY 10012 | Italian, Pizza | https://www.rubirosanyc.com/ |
| Wah Fung Fast Food | Grab and go | $ | Roast pork & chicken with rice | 79 Chrystie St, New York, NY 10002 | Chinese, Cantonese BBQ | https://www.yelp.com/biz/wah-fung-no-1-new-york-2 |
| Mekelburg's | Casual Fun | $$ | Matzo ball soup, Wings | 319 Kent Ave, Brooklyn, NY 11249, United States | Jewish Deli | https://www.yelp.com/biz/mekelburgs-brooklyn-3 |
Added rowUpdated cellDeleted rowThe last row (Mekelburg’s) was added by the AI.
Update: fix the restaurant URL
Now we’ll correct Mekelburg’s URL from Yelp to the official website.
update_prompt = "Change the URL for a restaurant named Mekelburg's to https://www.mekelburgs.com/."
update_ok = api.ai(
file_id=file_id,
prompt=update_prompt,
access_key=file_access_key,
secret_key=file_secret_key
)After UPDATE — one cell changed
| Name | Vibe | Price | Dishes | Address | Cuisine | URL |
|---|---|---|---|---|---|---|
| Medan Pesar | Casual | $$ | Beef rendang, BBQ Stingray | 102 E 7th St, New York, NY 10009 | Malaysian | http://medanpasar.com/ |
| Prince Street Pizza | Grab and go | $ | Square pepperoni slice | 27 Prince St A, New York, NY 10012 | Italian, Pizza | https://princestreetpizzanyc.com/ |
| Rubirosa | Nice Casual | $$ | Vodka pie | 235 Mulberry St, New York, NY 10012 | Italian, Pizza | https://www.rubirosanyc.com/ |
| Wah Fung Fast Food | Grab and go | $ | Roast pork & chicken with rice | 79 Chrystie St, New York, NY 10002 | Chinese, Cantonese BBQ | https://www.yelp.com/biz/wah-fung-no-1-new-york-2 |
| Mekelburg's | Casual Fun | $$ | Matzo ball soup, Wings | 319 Kent Ave, Brooklyn, NY 11249, United States | Jewish Deli | https://www.mekelburgs.com/ |
Added rowUpdated cellDeleted rowUpdated the URL cell for Mekelburg’s.
Read: query the spreadsheet
Ask questions about your data. For example, “Show me all restaurants in the East Village.” The AI returns JSON—use it in your app or print it for debugging.
read_prompt = "Show me all restaurants in the East Village"
east_village = api.ai(
file_id=file_id,
prompt=read_prompt,
access_key=file_access_key,
secret_key=file_secret_key
)
print(east_village) # => { "data": [...matching rows...] }Delete: remove a row by name
Finally, remove the row we added (Mekelburg’s) by referencing its name in natural language.
delete_prompt = "Remove the restaurant named Mekelburg's from this spreadsheet."
delete_ok = api.ai(
file_id=file_id,
prompt=delete_prompt,
access_key=file_access_key,
secret_key=file_secret_key
)After DELETE — Mekelburg’s removed
| Name | Vibe | Price | Dishes | Address | Cuisine | URL |
|---|---|---|---|---|---|---|
| Medan Pesar | Casual | $$ | Beef rendang, BBQ Stingray | 102 E 7th St, New York, NY 10009 | Malaysian | http://medanpasar.com/ |
| Prince Street Pizza | Grab and go | $ | Square pepperoni slice | 27 Prince St A, New York, NY 10012 | Italian, Pizza | https://princestreetpizzanyc.com/ |
| Rubirosa | Nice Casual | $$ | Vodka pie | 235 Mulberry St, New York, NY 10012 | Italian, Pizza | https://www.rubirosanyc.com/ |
| Wah Fung Fast Food | Grab and go | $ | Roast pork & chicken with rice | 79 Chrystie St, New York, NY 10002 | Chinese, Cantonese BBQ | https://www.yelp.com/biz/wah-fung-no-1-new-york-2 |
| Mekelburg's | Casual Fun | $$ | Matzo ball soup, Wings | 319 Kent Ave, Brooklyn, NY 11249, United States | Jewish Deli | https://www.yelp.com/biz/mekelburgs-brooklyn-3 |
Added rowUpdated cellDeleted rowThe Mekelburg’s row is deleted.
Tips for reliable prompts
- Match spelling exactly for entity names you reference (e.g., Mekelburg’s vs Mekelburgs).
- Use clear column hints (e.g., include “URL”, “Address”, “Cuisine” in your prompt when relevant).
- Include only one operation per request. Make multiple requests for multiple operations
- When updating, include both an identifier (Name/Address) and the new value you want.
