Google Sheets API Skill (Advanced)
Purpose
Provide a production-ready Google Sheets CLI for OpenClaw. This skill supports data reads/writes, batch operations, formatting, and sheet management with service account authentication.
Best fit
- You need a repeatable CLI for automation tasks.
- You want JSON-in/JSON-out for pipelines.
- You need more than basic read/write (formatting, sheet ops, batch updates).
Not a fit
- You must use end-user OAuth consent flows (this skill is service-account focused).
- You only need lightweight, one-off edits.
One-time setup
- Create or select a Google Cloud project.
- Enable the Google Sheets API.
- Create a service account and download its JSON key.
- Share target spreadsheets with the service account email.
Install
cd google-sheet-api
npm install
Run
node scripts/sheets-cli.js help
node scripts/sheets-cli.js read <spreadsheetId> "Sheet1!A1:C10"
node scripts/sheets-cli.js append <spreadsheetId> "Sheet1!A:B" '@data.json'
You can also use npm:
npm run sheets -- read <spreadsheetId> "Sheet1!A1:C10"
Credentials
Supported sources (first match wins):
GOOGLE_SHEETS_CREDENTIALS_JSON (inline JSON string)
GOOGLE_SERVICE_ACCOUNT_KEY (file path)
GOOGLE_SHEETS_KEY_FILE (file path)
GOOGLE_APPLICATION_CREDENTIALS (file path)
./service-account.json, ./credentials.json, ./google-service-account.json
~/.config/google-sheets/credentials.json
Input conventions
- JSON values can be inline or loaded from file using
@path.
- Write/append expect a 2D array of values.
Example data.json:
[["Name","Score"],["Alice",95]]
Command map (high level)
Data:
read, write, append, clear, batchGet, batchWrite
Formatting:
format, getFormat, borders, merge, unmerge, copyFormat
Layout:
resize, autoResize, freeze
Sheets:
create, info, addSheet, deleteSheet, renameSheet
Advanced:
batch (raw spreadsheets.batchUpdate requests)
Operational guidance
- Prefer read-only scope for read workflows when possible.
- Add retry with exponential backoff for
429 and transient 5xx errors.
- Keep request payloads small to avoid limit issues.
Expected output
- JSON to stdout; non-zero exit code on errors.
Security notes
- Never log or commit service account keys.
- Share spreadsheets only with the service account email required by this skill.
1---2name: google-sheet-api3description: OpenClaw skill that installs a Google Sheets CLI with setup steps and commands for read/write, batch, formatting, and sheet management.4---5
6# Google Sheets API Skill (Advanced)
7
8## Purpose
9Provide a production-ready Google Sheets CLI for OpenClaw. This skill supports data reads/writes, batch operations, formatting, and sheet management with service account authentication.
10
11## Best fit
12- You need a repeatable CLI for automation tasks.
13- You want JSON-in/JSON-out for pipelines.
14- You need more than basic read/write (formatting, sheet ops, batch updates).
15
16## Not a fit
17- You must use end-user OAuth consent flows (this skill is service-account focused).
18- You only need lightweight, one-off edits.
19
20## One-time setup
211. Create or select a Google Cloud project.
222. Enable the Google Sheets API.
233. Create a service account and download its JSON key.
244. Share target spreadsheets with the service account email.
25
26## Install
27```bash
28cd google-sheet-api
29npm install
30```
31
32## Run
33```bash
34node scripts/sheets-cli.js help
35node scripts/sheets-cli.js read <spreadsheetId> "Sheet1!A1:C10"
36node scripts/sheets-cli.js append <spreadsheetId> "Sheet1!A:B" '@data.json'
37```
38
39You can also use npm:
40```bash
41npm run sheets -- read <spreadsheetId> "Sheet1!A1:C10"
42```
43
44## Credentials
45Supported sources (first match wins):
46- `GOOGLE_SHEETS_CREDENTIALS_JSON` (inline JSON string)
47- `GOOGLE_SERVICE_ACCOUNT_KEY` (file path)
48- `GOOGLE_SHEETS_KEY_FILE` (file path)
49- `GOOGLE_APPLICATION_CREDENTIALS` (file path)
50- `./service-account.json`, `./credentials.json`, `./google-service-account.json`
51- `~/.config/google-sheets/credentials.json`
52
53## Input conventions
54- JSON values can be inline or loaded from file using `@path`.
55- Write/append expect a 2D array of values.
56
57Example `data.json`:
58```json
59[["Name","Score"],["Alice",95]]
60```
61
62## Command map (high level)
63Data:
64- `read`, `write`, `append`, `clear`, `batchGet`, `batchWrite`
65
66Formatting:
67- `format`, `getFormat`, `borders`, `merge`, `unmerge`, `copyFormat`
68
69Layout:
70- `resize`, `autoResize`, `freeze`
71
72Sheets:
73- `create`, `info`, `addSheet`, `deleteSheet`, `renameSheet`
74
75Advanced:
76- `batch` (raw `spreadsheets.batchUpdate` requests)
77
78## Operational guidance
79- Prefer read-only scope for read workflows when possible.
80- Add retry with exponential backoff for `429` and transient `5xx` errors.
81- Keep request payloads small to avoid limit issues.
82
83## Expected output
84- JSON to stdout; non-zero exit code on errors.
85
86## Security notes
87- Never log or commit service account keys.
88- Share spreadsheets only with the service account email required by this skill.