If you find this useful,
Skill Details
Back to Productivity

/google-sheets

by mrgoodb ยท View on GitHub

Read and write Google Sheets data. Create spreadsheets, update cells, and manage worksheets via Sheets API.

View on GitHub

Google Sheets

Spreadsheet automation.

Environment

export GOOGLE_ACCESS_TOKEN="ya29.xxxxxxxxxx"

Read Sheet Data

curl "https://sheets.googleapis.com/v4/spreadsheets/{spreadsheetId}/values/Sheet1!A1:D10" \
  -H "Authorization: Bearer $GOOGLE_ACCESS_TOKEN"

Write to Cells

curl -X PUT "https://sheets.googleapis.com/v4/spreadsheets/{spreadsheetId}/values/Sheet1!A1:B2?valueInputOption=USER_ENTERED" \
  -H "Authorization: Bearer $GOOGLE_ACCESS_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"values": [["Name", "Score"], ["Alice", 95]]}'

Append Rows

curl -X POST "https://sheets.googleapis.com/v4/spreadsheets/{spreadsheetId}/values/Sheet1!A:D:append?valueInputOption=USER_ENTERED" \
  -H "Authorization: Bearer $GOOGLE_ACCESS_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"values": [["New", "Row", "Data", "Here"]]}'

Create Spreadsheet

curl -X POST "https://sheets.googleapis.com/v4/spreadsheets" \
  -H "Authorization: Bearer $GOOGLE_ACCESS_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"properties": {"title": "My New Sheet"}}'

Get Spreadsheet Metadata

curl "https://sheets.googleapis.com/v4/spreadsheets/{spreadsheetId}" \
  -H "Authorization: Bearer $GOOGLE_ACCESS_TOKEN"

Clear Range

curl -X POST "https://sheets.googleapis.com/v4/spreadsheets/{spreadsheetId}/values/Sheet1!A1:Z100:clear" \
  -H "Authorization: Bearer $GOOGLE_ACCESS_TOKEN"

Links