This Google Apps Script integration brings the power of the Exa API directly into Google Sheets, allowing you to search the web, query information, find similar content, and extract website content without leaving your spreadsheet.
- EXA_ANSWER: Query the Exa AI to get answers to questions based on web search results
- EXA_SEARCH: Search the web and retrieve a list of relevant URLs
- EXA_CONTENTS: Extract the text content from specific URLs
- EXA_FINDSIMILAR: Find URLs similar to a provided reference URL
- API Key Management: Securely save your Exa API key
- Documentation: Built-in reference for all Exa functions and their parameters
- Batch Refresh: Refresh multiple Exa function cells at once
- Open your Google Sheet: Go to the Google Sheet where you want to use this script.
- Open the Script Editor: Click on "Extensions" > "Apps Script".
- Copy the Code:
- Copy the contents of
Code.gs
from this project and paste it into theCode.gs
file in the Apps Script editor. Overwrite any existing template code. - Create a new HTML file in the editor (File > New > HTML file). Name it
Sidebar.html
(ensure the name matches exactly, including capitalization). - Copy the contents of the
Sidebar.html
file from this project and paste it into the newly createdSidebar.html
file in the editor.
- Copy the contents of
- Save the Project: Click the floppy disk icon (Save project) and give your script project a name (e.g., "Exa for Sheets").
- Refresh Your Sheet: Close the Apps Script editor tab and refresh your Google Sheet browser tab.
- Authorize the Script:
- After refreshing, a new custom menu item "Exa AI" should appear. Click on it, then select "Open Sidebar".
- A dialog box will pop up asking for authorization. Review the permissions requested (it will need access to external services, script properties, and the current spreadsheet) and click "Allow". You might need to go through an "Advanced" > "Go to (project name)" flow if Google warns it's an unverified app.
- Set Your API Key:
- Once authorized, the sidebar will open with the API Key tab active.
- Go to https://exa.ai/ to get your API key if you don't have one.
- Paste your Exa API key into the input field in the sidebar and click "Save API Key".
- You should see a success message "API key saved successfully.".
The sidebar offers three main tabs:
- Set or update your Exa API key
- View status of key operations
- Refresh selected cells containing Exa functions
- Status updates for refresh operations
- Comprehensive documentation for all Exa functions
- Parameter descriptions and return value information
- Quick reference for function syntax
=EXA_ANSWER(prompt, [prefix], [suffix], [includeCitations])
Generates an AI answer based on search results for your query.
Parameters:
prompt
(required): The main question or promptprefix
(optional): Text to add before the main promptsuffix
(optional): Text to add after the main promptincludeCitations
(optional): If TRUE, includes source citations (Default: FALSE)
=EXA_SEARCH(query, [numResults], [searchType], [prefix], [suffix])
Searches the web and returns a vertical list of URLs.
Parameters:
query
(required): The search querynumResults
(optional): Number of results to return (1-10, Default: 1)searchType
(optional): "auto", "neural", or "keyword" (Default: "auto")prefix
(optional): Text to add before the main querysuffix
(optional): Text to add after the main query
=EXA_CONTENTS(url)
Retrieves the text content from a specified URL.
Parameters:
url
(required): The full URL to extract content from (must start with http/https)
=EXA_FINDSIMILAR(url, [numResults], [includeDomainsStr], [excludeDomainsStr], [includeTextStr], [excludeTextStr])
Finds URLs similar to the input URL.
Parameters:
url
(required): The reference URL to find similar contentnumResults
(optional): Number of results to return (1-10, Default: 1)includeDomainsStr
(optional): Comma-separated list of domains to includeexcludeDomainsStr
(optional): Comma-separated list of domains to excludeincludeTextStr
(optional): Phrase that must appear in resultsexcludeTextStr
(optional): Phrase that must not appear in results
To use batch refresh:
- Select cells containing Exa functions in your sheet
- Open the sidebar and navigate to the "Batch" tab
- Click Refresh Selected Cells to re-execute the Exa functions in selected cells
- Exa API requests count against your Exa usage quota
- For best performance, avoid excessive function calls in large sheets
- Functions will automatically refresh when their inputs change or when the sheet is reopened
- Your Exa API key is stored securely using Google Apps Script's User Properties service
- The key is only accessible to your Google account
- No data is stored outside of your Google account and the Exa API
-
Install dependencies:
npm install
-
Login to Google:
npm run login
-
Create a new Google Apps Script project:
npm run create
-
Push the code:
npm run push