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