{"id":17962732,"url":"https://github.com/fgribreau/google-spreadsheet-cli","last_synced_at":"2025-03-25T04:32:23.884Z","repository":{"id":57252348,"uuid":"89383633","full_name":"FGRibreau/google-spreadsheet-cli","owner":"FGRibreau","description":"📊  CLI for reading and writing data into Google Spreadsheet","archived":false,"fork":false,"pushed_at":"2023-05-22T19:19:34.000Z","size":56,"stargazers_count":52,"open_issues_count":1,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-08-10T21:28:24.981Z","etag":null,"topics":["cli","google","google-spreadsheet","google-spreadsheets","google-spreadsheets-parser","spreadsheet"],"latest_commit_sha":null,"homepage":"https://twitter.com/FGRibreau","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/FGRibreau.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2017-04-25T16:37:59.000Z","updated_at":"2023-05-22T19:19:39.000Z","dependencies_parsed_at":"2024-01-14T20:28:14.524Z","dependency_job_id":null,"html_url":"https://github.com/FGRibreau/google-spreadsheet-cli","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FGRibreau%2Fgoogle-spreadsheet-cli","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FGRibreau%2Fgoogle-spreadsheet-cli/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FGRibreau%2Fgoogle-spreadsheet-cli/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FGRibreau%2Fgoogle-spreadsheet-cli/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/FGRibreau","download_url":"https://codeload.github.com/FGRibreau/google-spreadsheet-cli/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":222035692,"owners_count":16919925,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cli","google","google-spreadsheet","google-spreadsheets","google-spreadsheets-parser","spreadsheet"],"created_at":"2024-10-29T11:20:26.311Z","updated_at":"2024-10-29T11:20:26.969Z","avatar_url":"https://github.com/FGRibreau.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"### 📊 Google Spreadsheet CLI\n\n[![Build Status](https://img.shields.io/circleci/project/FGRibreau/google-spreadsheet-cli.svg)](https://circleci.com/gh/FGRibreau/google-spreadsheet-cli/)\n[![Coverage Status](https://img.shields.io/coveralls/FGRibreau/google-spreadsheet-cli/master.svg)](https://coveralls.io/github/FGRibreau/google-spreadsheet-cli?branch=master)\n![deps](https://img.shields.io/david/fgribreau/google-spreadsheet-cli.svg?style=flat) ![Version](https://img.shields.io/npm/v/google-spreadsheet-cli.svg?style=flat) [![Docker hub](https://img.shields.io/docker/pulls/fgribreau/google-spreadsheet-cli.svg)](https://hub.docker.com/r/fgribreau/google-spreadsheet-cli/) [![available-for-advisory](https://img.shields.io/badge/available%20for%20consulting%20advisory-yes-ff69b4.svg?)](http://bit.ly/2c7uFJq) ![extra](https://img.shields.io/badge/actively%20maintained-yes-ff69b4.svg) [![Twitter Follow](https://img.shields.io/twitter/follow/fgribreau.svg?style=flat)](https://twitter.com/FGRibreau)\n\n\n## ❤️ Shameless plug\n- [Open-Source self-hostable or fully-managed **webhook as a service**](https://www.hook0.com/)\n- [**Charts, simple as a URL**. No more server-side rendering pain, 1 url = 1 chart](https://image-charts.com)\n- [Looking for a managed Keycloak IAM ?](https://www.cloud-iam.com/)\n\n## 📢 Features\n\n- List worksheets\n- Add worksheet\n- Remove worksheet\n- Append a row to a worksheet\n- Automatically adds the header row if it's missing\n- Permissive JSON format through [JSON5](http://json5.org/)\n- Available as a [docker image](https://hub.docker.com/r/fgribreau/google-spreadsheet-cli/)\n\n## 🎩 Authentication\n\nFirst thing first, you need your Google credentials, [follow the authentication instructions there](https://github.com/theoephraim/node-google-spreadsheet#service-account-recommended-method). Then save the JSON file somewhere, e.g. `~/myproject-8cbb20000000.json`.\n\nLocate the spreadsheet you want to work with, take the id from Google spreadsheet URL, e.g. `2CVmfghQmkMdLct11Tfo0aqv1WtnPA-chuYDUMEvoVPw`.\n\nIf you wish to directly pass the base64 stringified JSON as `--credentials` parameter you might first want to only keep `client_email` and `private_key` using [jq.node](https://github.com/FGRibreau/jq.node) like so:\n\n```bash\nexport CREDENTIALS=$(cat ~/myproject-8cbb20000000.json | jq -r btoa 'pick([\"client_email\", \"private_key\"]) | JSON.stringify | btoa')\n```\n\n## 😇 Documentation\n\n### `worksheets list`\n\nList spreadsheet document worksheets:\n\n```bash\ngoogle-spreadsheet-cli \\\n  --id 2CVmfghQmkMdLct11Tfo0aqv1WtnPA-chuYDUMEvoVPw \\\n  --credentials ~/myproject-8cbb20000000.json \\\n  worksheets list\n\n{\"id\":\"od6\",\"title\":\"my first worksheet\"}\n{\"id\":\"od7\",\"title\":\"my second worksheet\"}\n{\"id\":\"ad7\",\"title\":\"oh oh oh the last one\"}\n```\n\n... or you could also pass the credential as a JSON base64 encoded string:\n\n```bash\ngoogle-spreadsheet-cli \\\n  --id 2CVmfghQmkMdLct11Tfo0aqv1WtnPA-chuYDUMEvoVPw \\\n  --credentials $CREDENTIALS \\\n  worksheets list\n\n{\"id\":\"od6\",\"title\":\"my first worksheet\"}\n{\"id\":\"od7\",\"title\":\"my second worksheet\"}\n{\"id\":\"ad7\",\"title\":\"oh oh oh the last one\"}\n```\n\n### `worksheets add \u003ctitle\u003e`\n\nAdd a worksheet to the spreadsheet document:\n\n```bash\n$ google-spreadsheet-cli \\\n  --id 2CVmfghQmkMdLct11Tfo0aqv1WtnPA-chuYDUMEvoVPw \\\n  --credentials $CREDENTIALS \\\n  worksheets \\\n  add my_awesome_worksheet\n\n{\"id\":\"oy7n5ch\",\"title\":\"my_awesome_worksheet\",\"rowCount\":50,\"colCount\":20,\"url\":\"https://spreadsheets.google.com/feeds/worksheets/2CVmfghQmkMdLct11Tfo0aqv1WtnPA-chuYDUMEvoVPw/oy7n5ch\"}\n```\n\nOther options:\n\n```bash\n  --spreadsheetId, --id   spreadsheet id, the long id in the sheets URL  [required]\n  --credentials, --creds  json credential path (use environment variable to specify a JSON stringified credential in base64)  [required]\n  --rowCount, --row       number of rows  [default: 50]\n  --colCount, --col       number of columns  [default: 20]\n  -h, --help              Show help  [boolean]\n```\n\n### `worksheets remove \u003cworksheetId\u003e`\n\nRemove a worksheet from the spreadsheet document:\n\n```bash\n$ google-spreadsheet-cli \\\n  --id 2CVmfghQmkMdLct11Tfo0aqv1WtnPA-chuYDUMEvoVPw \\\n  --credentials $CREDENTIALS \\\n  worksheets \\\n  remove od6\n\n{\"status\": \"success\"}\n```\n\n### `worksheets get --worksheetId {worksheetId} append --json`\n\nAppend a row to a worksheet. Once you got the `worksheetId` it's really simple to append a row:\n\n#### Passing raw JSON\n\n```bash\n$ google-spreadsheet-cli \\\n  --id 2CVmfghQmkMdLct11Tfo0aqv1WtnPA-chuYDUMEvoVPw \\\n  --credentials $CREDENTIALS \\\n  worksheets \\\n  get --worksheetId od6 \\\n  append --json '{a:1, b:2, c:3}'\n\n{\"content\":\"b: 2, c: 3\",\"title\":\"1\",\"updated\":\"2017-04-26T21:46:22.201Z\",\"id\":\"https://spreadsheets.google.com/feeds/list/2CVmfghQmkMdLct11Tfo0aqv1WtnPA-chuYDUMEvoVPw/od6/cpzh4\"}\n```\n\nNote that the JSON data we passed was not strictly valid still it worked thanks to [JSON5](https://json5.org).\n\n#### Passing base64 encoded JSON\n\nAs soon as you will have quotes or special characters inside your JSON, things are going to be messy. Fortunately you can also pass a base64 encoded JSON to `--json`.\n\n```bash\n$ JSON=$(echo '{a:1, b:2, c:3}' | base64)\n\n$ echo $JSON\ne2E6MSwgYjoyLCBjOjN9Cg==\n\n$ google-spreadsheet-cli \\\n  --id 2CVmfghQmkMdLct11Tfo0aqv1WtnPA-chuYDUMEvoVPw \\\n  --credentials $CREDENTIALS \\\n  worksheets \\\n  get --worksheetId od6 \\\n  append --json $JSON\n\n{\"content\":\"b: 2, c: 3\",\"title\":\"1\",\"updated\":\"2017-04-26T21:46:22.201Z\",\"id\":\"https://spreadsheets.google.com/feeds/list/2CVmfghQmkMdLct11Tfo0aqv1WtnPA-chuYDUMEvoVPw/od6/cpzh4\"}\n```\n\n## Setup (docker 🐳)\n\nUse this approach if you don't know/want to setup your NodeJS environment, that's what containers are good for.\n\n```shell\n# open ~/.bashrc  (or equivalent)\nnano ~/.bashrc\n\n# edit it\nfunction google-spreadsheet-cli(){\n docker run -i --rm fgribreau/google-spreadsheet-cli:latest $@\n}\n\n# save it\n\n# source it\nsource ~/.bashrc\n\n# run it!\ngoogle-spreadsheet-cli \\\n  --id 2CVmfghQmkMdLct11Tfo0aqv1WtnPA-chuYDUMEvoVPw \\\n  --credentials $CREDENTIALS \\\n  worksheets \\\n  get --worksheetId od6 \\\n  append --json '{a:1, b:2, c:3}'\n\n# done!\n```\n\n## Setup (NodeJS)\n\n```\nnpm i google-spreadsheet-cli -g\n```\n\n## [Changelog](/CHANGELOG.md)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffgribreau%2Fgoogle-spreadsheet-cli","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffgribreau%2Fgoogle-spreadsheet-cli","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffgribreau%2Fgoogle-spreadsheet-cli/lists"}