{"id":18034697,"url":"https://github.com/yuanqing/google-sheets","last_synced_at":"2025-09-06T19:40:06.597Z","repository":{"id":57169972,"uuid":"196978322","full_name":"yuanqing/google-sheets","owner":"yuanqing","description":":leaves: An easier interface to read from and write to Google Sheets","archived":false,"fork":false,"pushed_at":"2021-01-30T07:40:32.000Z","size":704,"stargazers_count":1,"open_issues_count":3,"forks_count":1,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-08-31T06:32:01.874Z","etag":null,"topics":["google-api","google-sheets","spreadsheet"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yuanqing.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-07-15T10:36:02.000Z","updated_at":"2021-01-30T07:40:35.000Z","dependencies_parsed_at":"2022-08-27T12:01:53.652Z","dependency_job_id":null,"html_url":"https://github.com/yuanqing/google-sheets","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/yuanqing/google-sheets","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yuanqing%2Fgoogle-sheets","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yuanqing%2Fgoogle-sheets/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yuanqing%2Fgoogle-sheets/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yuanqing%2Fgoogle-sheets/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yuanqing","download_url":"https://codeload.github.com/yuanqing/google-sheets/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yuanqing%2Fgoogle-sheets/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273955164,"owners_count":25197577,"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","status":"online","status_checked_at":"2025-09-06T02:00:13.247Z","response_time":2576,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["google-api","google-sheets","spreadsheet"],"created_at":"2024-10-30T11:13:27.009Z","updated_at":"2025-09-06T19:40:06.573Z","avatar_url":"https://github.com/yuanqing.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# @yuanqing/google-sheets [![npm Version](https://badgen.net/npm/v/@yuanqing/google-sheets)](https://www.npmjs.org/package/@yuanqing/google-sheets) [![Build Status](https://badgen.net/travis/yuanqing/google-sheets?label=build)](https://travis-ci.org/yuanqing/google-sheets)\n\n\u003e An easier interface to read from and write to Google Sheets\n\n## Quick start\n\n```sh\n$ yarn add @yuanqing/google-sheets\n```\n\n```js\nconst { getSpreadsheet } = require('@yuanqing/google-sheets')\n\nasync function main () {\n  const serviceAccountCredentials = {\n    clientEmail: '\u003cclient_email\u003e',\n    priateKey: '\u003cprivate_key\u003e'\n  }\n  const spreadsheetId = '\u003cspreadsheet_id\u003e'\n  const sheetName = '\u003csheet_name\u003e'\n  const spreadsheet = await getSpreadsheet(\n    serviceAccountCredentials,\n    spreadsheetId\n  )\n  const sheet = await spreadsheet.getSheet(sheetName)\n  const rows = await sheet.getAllRows()\n  console.log(rows)\n}\n\nawait main()\n```\n\n- **`\u003cclient_email\u003e`** and **`\u003cprivate_key\u003e`** are credentials for a Service Account with edit access to your spreadsheet. See [Initial setup](#initial-setup).\n- **`\u003cspreadsheet_id\u003e`** is the value between `/d/` and `/edit` in your spreadsheet URL.\n- **`\u003csheet_name\u003e`** is the name of the sheet that you want to read from or write to.\n\n### Initial setup\n\n\u003cdetails\u003e\n\u003csummary\u003e1. Create a Service Account on the Google API Console.\u003c/summary\u003e\n\u003cp\u003e\n\n1. Navigate to [the Google API Console](https://console.developers.google.com/apis/dashboard)\n2. Select a project from the drop-down box in the top bar.\n3. Click **`Credentials`** (the Key icon) on the left navigation bar.\n4. Click the **`Create credentials`** drop-down box, and select **`Service account key`**.\n5. Click the **`Select…`** drop-down box, and select **`New service account`**. Enter a **`Service account name`**. For **`Role`**, select **`Project › Editor`**.\n6. For **`Key type`**, select **`JSON`**.\n7. Click the **`Create`** button. A JSON file with the Service Account credentials will be generated. Note the `client_email` and `private_key` values in the generated JSON file.\n\n\u003c/p\u003e\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e2. Grant the Service Account edit access to your spreadsheet.\u003c/summary\u003e\n\u003cp\u003e\n\n1. Navigate to your spreadsheet.\n2. Click the **`Share`** button on the top-right corner of the page.\n3. In the **`Enter names or email addresses…`** text box, enter the `client_email` of the Service Account, then click the **`Send`** button.\n\n\u003c/p\u003e\n\u003c/details\u003e\n\n### Assumptions\n\n1. Data is row-based. Each field is stored on a column.\n2. Row 1 of the sheet contains the headers for the data. “Actual” data starts from Row 2.\n\n[![Google Sheets](/media/header.png)](https://docs.google.com/spreadsheets/d/1ur-Bd1PBUpkXs18u4VeSy85q9wSYf2db9hUi73aWbSY/edit#gid=0)\n\n\u003e [**Example spreadsheet**](https://docs.google.com/spreadsheets/d/1ur-Bd1PBUpkXs18u4VeSy85q9wSYf2db9hUi73aWbSY/edit#gid=0)\n\n## API\n\n```js\nconst { createSpreadsheet, getSpreadsheet } = require('@yuanqing/google-sheets')\n```\n\n### Spreadsheet\n\n#### const spreadsheet = await createSpreadsheet(serviceAccountCredentials)\n\nCreates a new spreadsheet and returns a Promise for it.\n\n- `serviceAccountCredentials` is an object literal with the following keys:\n\n    Key | Description\n    :-|:-\n    `clientEmail` | Email address of the Service Account that has edit access to the spreadsheet.\n    `privateKey` | Private key of the Service Account.\n\n#### const spreadsheet = await getSpreadsheet(serviceAccountCredentials, spreadsheetId)\n\nReturns a Promise for an existing spreadsheet.\n\n- `spreadsheetId` is the value between `/d/` and `/edit` in the spreadsheet URL.\n\n#### const sheet = await spreadsheet.createSheet(spreadsheetName, headers)\n\nCreates a new sheet and returns a Promise for it.\n\n- `spreadsheetName` is the name of the new sheet.\n- `headers` is an array of headers for the new sheet.\n\n#### const sheet = await spreadsheet.getSheet(spreadsheetName)\n\nReturns a Promise for an existing sheet.\n\n### Sheet\n\n#### const rows = await sheet.getAllRows()\n\nReturns a Promise for an array containing all the `rows` from the `sheet`.\n\n#### const rows = await sheet.getRowsByRange(m, n)\n\nReturns a Promise for an array containing `rows` from the row `m` to row `n` of the `sheet`.\n\nData rows are zero-indexed. For example, pass in `(0, 1)` to delete rows 2 and 3 in the `sheet`.\n\n#### await sheet.addRows(rows)\n\nAppends the given array of `rows` to the `sheet`, and returns a Promise that resolves.\n\n#### const deletedRows = await sheet.deleteRows(predicate)\n\nDeletes rows in the `sheet` that satisfy the given `predicate`, and returns a Promise for an array containing the deleted rows.\n\n## Installation\n\n```sh\n$ yarn add @yuanqing/google-sheets\n```\n\n## License\n\n[MIT](LICENSE.md)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyuanqing%2Fgoogle-sheets","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyuanqing%2Fgoogle-sheets","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyuanqing%2Fgoogle-sheets/lists"}