{"id":13769325,"url":"https://theoephraim.github.io/node-google-spreadsheet/","last_synced_at":"2025-05-11T02:32:04.945Z","repository":{"id":7242644,"uuid":"8552709","full_name":"theoephraim/node-google-spreadsheet","owner":"theoephraim","description":"Google Sheets API wrapper for Javascript / Typescript","archived":false,"fork":false,"pushed_at":"2024-10-05T04:01:43.000Z","size":1381,"stargazers_count":2334,"open_issues_count":72,"forks_count":390,"subscribers_count":26,"default_branch":"main","last_synced_at":"2024-11-14T08:12:41.718Z","etag":null,"topics":["google","google-sheets","google-sheets-api-v4","google-spreadsheets","nodejs","typescript"],"latest_commit_sha":null,"homepage":"https://theoephraim.github.io/node-google-spreadsheet","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"unlicense","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/theoephraim.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","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,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":["theoephraim"],"custom":["https://buymeacoffee.com/theo.dmno"]}},"created_at":"2013-03-04T09:53:48.000Z","updated_at":"2024-11-12T11:38:07.000Z","dependencies_parsed_at":"2023-01-13T14:19:08.849Z","dependency_job_id":"4b026257-1f9c-4201-99b1-ac25eb66292f","html_url":"https://github.com/theoephraim/node-google-spreadsheet","commit_stats":{"total_commits":224,"total_committers":56,"mean_commits":4.0,"dds":0.6428571428571428,"last_synced_commit":"456ce2563db894ed9db541c26dc415f7bfde01b6"},"previous_names":[],"tags_count":50,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/theoephraim%2Fnode-google-spreadsheet","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/theoephraim%2Fnode-google-spreadsheet/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/theoephraim%2Fnode-google-spreadsheet/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/theoephraim%2Fnode-google-spreadsheet/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/theoephraim","download_url":"https://codeload.github.com/theoephraim/node-google-spreadsheet/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224703869,"owners_count":17355710,"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":["google","google-sheets","google-sheets-api-v4","google-spreadsheets","nodejs","typescript"],"created_at":"2024-08-03T17:00:21.960Z","updated_at":"2025-05-11T02:32:04.931Z","avatar_url":"https://github.com/theoephraim.png","language":"TypeScript","funding_links":["https://github.com/sponsors/theoephraim","https://buymeacoffee.com/theo.dmno","https://paypal.me/theoephraim"],"categories":["Showcase"],"sub_categories":[],"readme":"# google-spreadsheet\n\n\u003e The most popular [Google Sheets API](https://developers.google.com/sheets/api/guides/concepts) wrapper for javascript / typescript\n\n[![NPM version](https://img.shields.io/npm/v/google-spreadsheet)](https://www.npmjs.com/package/google-spreadsheet)\n[![CI status](https://github.com/theoephraim/node-google-spreadsheet/actions/workflows/ci.yml/badge.svg)](https://github.com/theoephraim/node-google-spreadsheet/actions/workflows/ci.yml)\n[![Known Vulnerabilities](https://snyk.io/test/github/theoephraim/node-google-spreadsheet/badge.svg?targetFile=package.json)](https://snyk.io/test/github/theoephraim/node-google-spreadsheet?targetFile=package.json)\n[![NPM](https://img.shields.io/npm/dw/google-spreadsheet)](https://www.npmtrends.com/google-spreadsheet)\n\n- multiple auth options (via [google-auth-library](https://www.npmjs.com/package/google-auth-library)) - service account, OAuth, API key, ADC, etc\n- cell-based API - read, write, bulk-updates, formatting\n- row-based API - read, update, delete (based on the old v3 row-based calls)\n- managing worksheets - add, remove, resize, update properties (ex: title), duplicate to same or other document\n- managing docs - create new doc, delete doc, basic sharing/permissions\n- export - download sheet/docs in various formats\n\n**Docs site -**\nFull docs available at [https://theoephraim.github.io/node-google-spreadsheet](https://theoephraim.github.io/node-google-spreadsheet)\n\n---\n\n\u003e 🌈 **Installation** - `pnpm i google-spreadsheet`\u003cbr/\u003e(or `npm i google-spreadsheet --save` or `yarn add google-spreadsheet`)\n\n## Examples\n\n_The following examples are meant to give you an idea of just some of the things you can do_\n\n\u003e **IMPORTANT NOTE** - To keep the examples concise, I'm calling await [at the top level](https://v8.dev/features/top-level-await) which is not allowed in some older versions of node. If you need to call await in a script at the root level and your environment does not support it, you must instead wrap it in an async function like so:\n\n```javascript\n(async function () {\n  await someAsyncFunction();\n})();\n```\n\n### The Basics\n\n```js\nimport { GoogleSpreadsheet } from 'google-spreadsheet';\nimport { JWT } from 'google-auth-library';\n\n// Initialize auth - see https://theoephraim.github.io/node-google-spreadsheet/#/guides/authentication\nconst serviceAccountAuth = new JWT({\n  // env var values here are copied from service account credentials generated by google\n  // see \"Authentication\" section in docs for more info\n  email: process.env.GOOGLE_SERVICE_ACCOUNT_EMAIL,\n  key: process.env.GOOGLE_PRIVATE_KEY,\n  scopes: ['https://www.googleapis.com/auth/spreadsheets'],\n});\n\nconst doc = new GoogleSpreadsheet('\u003cthe sheet ID from the url\u003e', serviceAccountAuth);\n\nawait doc.loadInfo(); // loads document properties and worksheets\nconsole.log(doc.title);\nawait doc.updateProperties({ title: 'renamed doc' });\n\nconst sheet = doc.sheetsByIndex[0]; // or use `doc.sheetsById[id]` or `doc.sheetsByTitle[title]`\nconsole.log(sheet.title);\nconsole.log(sheet.rowCount);\n\n// adding / removing sheets\nconst newSheet = await doc.addSheet({ title: 'another sheet' });\nawait newSheet.delete();\n```\n\nMore info:\n\n- [GoogleSpreadsheet](https://theoephraim.github.io/node-google-spreadsheet/#/classes/google-spreadsheet)\n- [GoogleSpreadsheetWorksheet](https://theoephraim.github.io/node-google-spreadsheet/#/classes/google-spreadsheet-worksheet)\n- [Authentication](https://theoephraim.github.io/node-google-spreadsheet/#/guides/authentication)\n\n### Working with rows\n\n```js\n// if creating a new sheet, you can set the header row\nconst sheet = await doc.addSheet({ headerValues: ['name', 'email'] });\n\n// append rows\nconst larryRow = await sheet.addRow({ name: 'Larry Page', email: 'larry@google.com' });\nconst moreRows = await sheet.addRows([\n  { name: 'Sergey Brin', email: 'sergey@google.com' },\n  { name: 'Eric Schmidt', email: 'eric@google.com' },\n]);\n\n// read rows\nconst rows = await sheet.getRows(); // can pass in { limit, offset }\n\n// read/write row values\nconsole.log(rows[0].get('name')); // 'Larry Page'\nrows[1].set('email', 'sergey@abc.xyz'); // update a value\nrows[2].assign({ name: 'Sundar Pichai', email: 'sundar@google.com' }); // set multiple values\nawait rows[2].save(); // save updates on a row\nawait rows[2].delete(); // delete a row\n```\n\nRow methods support explicit TypeScript types for shape of the data\n\n```typescript\ntype UsersRowData = {\n  name: string;\n  email: string;\n  type?: 'admin' | 'user';\n};\nconst userRows = await sheet.getRows\u003cUsersRowData\u003e();\n\nuserRows[0].get('name'); // \u003c- TS is happy, knows it will be a string\nuserRows[0].get('badColumn'); // \u003c- will throw a type error\n```\n\nMore info:\n\n- [GoogleSpreadsheetWorksheet \u003e Working With Rows](https://theoephraim.github.io/node-google-spreadsheet/#/classes/google-spreadsheet-worksheet#working-with-rows)\n- [GoogleSpreadsheetRow](https://theoephraim.github.io/node-google-spreadsheet/#/classes/google-spreadsheet-row)\n\n### Working with cells\n\n```js\nawait sheet.loadCells('A1:E10'); // loads range of cells into local cache - DOES NOT RETURN THE CELLS\nconsole.log(sheet.cellStats); // total cells, loaded, how many non-empty\nconst a1 = sheet.getCell(0, 0); // access cells using a zero-based index\nconst c6 = sheet.getCellByA1('C6'); // or A1 style notation\n// access everything about the cell\nconsole.log(a1.value);\nconsole.log(a1.formula);\nconsole.log(a1.formattedValue);\n// update the cell contents and formatting\na1.value = 123.456;\nc6.formula = '=A1';\na1.textFormat = { bold: true };\nc6.note = 'This is a note!';\nawait sheet.saveUpdatedCells(); // save all updates in one call\n```\n\nMore info:\n\n- [GoogleSpreadsheetWorksheet \u003e Working With Cells](https://theoephraim.github.io/node-google-spreadsheet/#/classes/google-spreadsheet-worksheet#working-with-cells)\n- [GoogleSpreadsheetCell](https://theoephraim.github.io/node-google-spreadsheet/#/classes/google-spreadsheet-cell)\n\n### Managing docs and sharing\n\n```js\nconst auth = new JWT({\n  email: process.env.GOOGLE_SERVICE_ACCOUNT_EMAIL,\n  key: process.env.GOOGLE_PRIVATE_KEY,\n  scopes: [\n    'https://www.googleapis.com/auth/spreadsheets',\n    // note that sharing-related calls require the google drive scope\n    'https://www.googleapis.com/auth/drive.file',\n  ],\n});\n\n// create a new doc\nconst newDoc = await GoogleSpreadsheet.createNewSpreadsheetDocument(auth, { title: 'new fancy doc' });\n\n// share with specific users, domains, or make public\nawait newDoc.share('someone.else@example.com');\nawait newDoc.share('mycorp.com');\nawait newDoc.setPublicAccessLevel('reader');\n\n// delete doc\nawait newDoc.delete();\n```\n\n## Why?\n\n\u003e **This module provides an intuitive wrapper around Google's API to simplify common interactions**\n\nWhile Google's v4 sheets API is much easier to use than v3 was, the official [googleapis npm module](https://www.npmjs.com/package/googleapis) is a giant autogenerated meta-tool that handles _every Google product_. The module and the API itself are awkward and the docs are pretty terrible, at least to get started.\n\n**In what situation should you use Google's API directly?**\u003cbr\u003e\nThis module makes trade-offs for simplicity of the interface.\nGoogle's API provides a mechanism to make many requests in parallel, so if speed and efficiency are extremely important to your use case, you may want to use their API directly. There are also many lesser-used features of their API that are not implemented here yet.\n\n## Support \u0026 Contributions\n\nThis module was written and is actively maintained by [Theo Ephraim](https://theoephraim.com).\n\n**Are you actively using this module for a commercial project? Want to help support it?**\u003cbr\u003e\n[Buy Theo a beer](https://paypal.me/theoephraim)\n\n### Sponsors\n\nNone yet - get in touch!\n\n### Contributing\n\nContributions are welcome, but please follow the existing conventions, use the linter, add relevant tests, and add relevant documentation.\n\nThe docs site is generated using [docsify](https://docsify.js.org). To preview and run locally so you can make edits, run `npm run docs:preview` and head to http://localhost:3000\nThe content lives in markdown files in the docs folder.\n\n## License\n\nThis project is released under the MIT license. Previously it was using the \"Unlicense\". TLDR do whatever you want with it.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/theoephraim.github.io%2Fnode-google-spreadsheet%2F","html_url":"https://awesome.ecosyste.ms/projects/theoephraim.github.io%2Fnode-google-spreadsheet%2F","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/theoephraim.github.io%2Fnode-google-spreadsheet%2F/lists"}