API Spreadsheets Logo

Using the /ai endpoint

API Spreadsheets Team ·

Using the /ai endpoint

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

Where to find your account keys

Dashboard → API Keys (Account Access Key & Secret Key)
Dashboard → API Keys (Account Access Key & Secret Key)

Where to find your File ID and File Keys

Files → Select a file → Copy File ID, File Access Key & File Secret Key
Files → Select a file → Copy File ID, File Access Key & File Secret Key

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
NameVibePriceDishesAddressCuisineURL
Medan PesarCasual$$Beef rendang, BBQ Stingray102 E 7th St, New York, NY 10009Malaysianhttp://medanpasar.com/
Prince Street PizzaGrab and go$Square pepperoni slice27 Prince St A, New York, NY 10012Italian, Pizzahttps://princestreetpizzanyc.com/
RubirosaNice Casual$$Vodka pie235 Mulberry St, New York, NY 10012Italian, Pizzahttps://www.rubirosanyc.com/
Wah Fung Fast FoodGrab and go$Roast pork & chicken with rice79 Chrystie St, New York, NY 10002Chinese, Cantonese BBQhttps://www.yelp.com/biz/wah-fung-no-1-new-york-2
Thai DinerNice Casual$$Khao Soi, Larb186 Mott St, New York, NY 10012Thaihttps://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
NameVibePriceDishesAddressCuisineURL
Medan PesarCasual$$Beef rendang, BBQ Stingray102 E 7th St, New York, NY 10009Malaysianhttp://medanpasar.com/
Prince Street PizzaGrab and go$Square pepperoni slice27 Prince St A, New York, NY 10012Italian, Pizzahttps://princestreetpizzanyc.com/
RubirosaNice Casual$$Vodka pie235 Mulberry St, New York, NY 10012Italian, Pizzahttps://www.rubirosanyc.com/
Wah Fung Fast FoodGrab and go$Roast pork & chicken with rice79 Chrystie St, New York, NY 10002Chinese, Cantonese BBQhttps://www.yelp.com/biz/wah-fung-no-1-new-york-2
Mekelburg'sCasual Fun$$Matzo ball soup, Wings319 Kent Ave, Brooklyn, NY 11249, United StatesJewish Delihttps://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
NameVibePriceDishesAddressCuisineURL
Medan PesarCasual$$Beef rendang, BBQ Stingray102 E 7th St, New York, NY 10009Malaysianhttp://medanpasar.com/
Prince Street PizzaGrab and go$Square pepperoni slice27 Prince St A, New York, NY 10012Italian, Pizzahttps://princestreetpizzanyc.com/
RubirosaNice Casual$$Vodka pie235 Mulberry St, New York, NY 10012Italian, Pizzahttps://www.rubirosanyc.com/
Wah Fung Fast FoodGrab and go$Roast pork & chicken with rice79 Chrystie St, New York, NY 10002Chinese, Cantonese BBQhttps://www.yelp.com/biz/wah-fung-no-1-new-york-2
Mekelburg'sCasual Fun$$Matzo ball soup, Wings319 Kent Ave, Brooklyn, NY 11249, United StatesJewish Delihttps://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
NameVibePriceDishesAddressCuisineURL
Medan PesarCasual$$Beef rendang, BBQ Stingray102 E 7th St, New York, NY 10009Malaysianhttp://medanpasar.com/
Prince Street PizzaGrab and go$Square pepperoni slice27 Prince St A, New York, NY 10012Italian, Pizzahttps://princestreetpizzanyc.com/
RubirosaNice Casual$$Vodka pie235 Mulberry St, New York, NY 10012Italian, Pizzahttps://www.rubirosanyc.com/
Wah Fung Fast FoodGrab and go$Roast pork & chicken with rice79 Chrystie St, New York, NY 10002Chinese, Cantonese BBQhttps://www.yelp.com/biz/wah-fung-no-1-new-york-2
Mekelburg'sCasual Fun$$Matzo ball soup, Wings319 Kent Ave, Brooklyn, NY 11249, United StatesJewish Delihttps://www.yelp.com/biz/mekelburgs-brooklyn-3
Added rowUpdated cellDeleted rowThe Mekelburg’s row is deleted.

Tips for reliable prompts