{"id":17188815,"url":"https://github.com/butlerx/gatsby-source-google-spreadsheets","last_synced_at":"2025-04-13T19:22:44.352Z","repository":{"id":42959220,"uuid":"229737614","full_name":"butlerx/gatsby-source-google-spreadsheets","owner":"butlerx","description":"A source plugin for Gatsby that allows reading data from Google Sheets.","archived":false,"fork":false,"pushed_at":"2024-03-15T13:33:50.000Z","size":650,"stargazers_count":39,"open_issues_count":7,"forks_count":10,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-27T10:02:25.423Z","etag":null,"topics":["gatsby","google-sheets","google-spreadsheet"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/butlerx.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2019-12-23T11:19:39.000Z","updated_at":"2024-10-17T20:36:46.000Z","dependencies_parsed_at":"2023-11-12T12:28:29.578Z","dependency_job_id":"51ca3337-b513-4859-9cf7-7a4d83468e9d","html_url":"https://github.com/butlerx/gatsby-source-google-spreadsheets","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/butlerx%2Fgatsby-source-google-spreadsheets","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/butlerx%2Fgatsby-source-google-spreadsheets/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/butlerx%2Fgatsby-source-google-spreadsheets/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/butlerx%2Fgatsby-source-google-spreadsheets/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/butlerx","download_url":"https://codeload.github.com/butlerx/gatsby-source-google-spreadsheets/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248766688,"owners_count":21158302,"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":["gatsby","google-sheets","google-spreadsheet"],"created_at":"2024-10-15T01:09:55.415Z","updated_at":"2025-04-13T19:22:44.309Z","avatar_url":"https://github.com/butlerx.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Welcome to gatsby-source-google-spreadsheets 👋\n\n[![Version](https://img.shields.io/npm/v/gatsby-source-google-spreadsheets.svg)](https://www.npmjs.com/package/gatsby-source-google-spreadsheets)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://github.com/butlerx/gatsby-source-google-spreadsheets/blob/master/LICENSE)\n[![file structure: destiny](https://img.shields.io/badge/file%20structure-destiny-7a49ff?style=flat)](https://github.com/benawad/destiny)\n[![Twitter: cianbutlerx](https://img.shields.io/twitter/follow/cianbutlerx.svg?style=social)](https://twitter.com/cianbutlerx)\n\n\u003e A source plugin for Gatsby that allows reading data from Google Sheets.\n\nForked from\n[brandonmp/gatsby-source-google-sheets](https://github.com/brandonmp/gatsby-source-google-sheets)\nto allow pulling the entire sheet as an objects and using public sheets\n\nWhy go through the hassle of setting up a complicated headless CMS when Google\nSheets already has user permissions, revision history, and a powerful UI?\n\nThis source plugin for [Gatsby JS](https://github.com/gatsbyjs/gatsby) will turn\nany Google Sheets worksheet into a GraphQL type for build-time consumption.\n\n### ✨ [Demo](https://beer.notthe.cloud)\n\n## Install\n\n```sh\nyarn add gatsby-source-google-spreadsheets\n```\n\n## Usage\n\n### Step 1: Set up your google project \u0026 enable the sheets API\n\n1. Go to the [Google Developers Console](https://console.developers.google.com/)\n1. Select your project or create a new one (and then select it)\n1. Enable the Sheets API for your project\n   - In the sidebar on the left, select **APIs \u0026 Services \u003e Library**\n   - Search for \"sheets\"\n   - Click on \"Google Sheets API\"\n   - click the blue \"Enable\" button\n\n### Step 2: set up sheets/permissions\n\nNext you need to decide if you wish to authenticate with a service account or an\nAPI key.\n\n1. Create a service account for your project\n   - In the sidebar on the left, select **APIs \u0026 Services \u003e Credentials**\n   - Click blue \"+ CREATE CREDENITALS\" and select \"Service account\" option\n   - Enter name, description, click \"CREATE\"\n   - You can skip permissions, click \"CONTINUE\"\n   - Click \"+ CREATE KEY\" button\n   - Select the \"JSON\" key type option\n   - Click \"Create\" button\n   - your JSON key file is generated and downloaded to your machine (**it is the\n     only copy!**)\n   - click \"DONE\"\n   - note your service account's email address (also available in the JSON key\n     file)\n1. Open your google sheet, click \"File \u003e Share...\" and enter your service\n   account's e-mail address (you can find it in the credentials file).\n\nOr if you wish to use an API Key not only must the Spreadsheet in question be\nvisible to the web, but it must also have been explicitly published.\n\n1. Create an API key for your project\n   - In the sidebar on the left, select **Credentials**\n   - Click blue \"+ CREATE CREDENITALS\" and select \"API key\" option\n   - Copy the API key\n1. OPTIONAL - click \"Restrict key\" on popup to set up restrictions\n   - Click \"API restrictions\" \u003e Restrict Key\"\n   - Check the \"Google Sheets API\" checkbox\n   - Click \"Save\"\n1. Open your google sheet, Click \"File \u003e Publish to the web\" and Share entire\n   sheet or specific worksheets.\n1. Click \"File \u003e Share\" and click \"Get Shareable Link\", the link should look\n   like\n   `https://docs.google.com/spreadsheets/d/$SPREADSHEET_ID/edit?usp=sharing`\n\n### Step 2: configure your gatsby project\n\nStandard source plugin installation.\n\n```js\n// gatsby-config.js\n// ...\n{\n  resolve: 'gatsby-source-google-spreadsheets',\n  options: {\n    spreadsheetId: 'get this from the sheet url',\n    apiKey: 'GOOGLE-API-KEY'\n    // Or\n    credentials: require('./path-to-credentials-file.json')\n  }\n},\n// OR using environment variables\n{\n  resolve: 'gatsby-source-google-spreadsheets',\n  options: {\n    spreadsheetId: process.env.SPREADSHEET_ID,\n    apiKey: process.env.GOOGLE_API_KEY,\n    // OR\n    credentials: {\n      type: 'service_account',\n      project_id: process.env.PROJECT_ID,\n      private_key_id: process.env.PRIVATE_KEY_ID,\n      private_key: process.env.PRIVATE_KEY.replace(/(\\\\r)|(\\\\n)/g, '\\n'),\n      client_email: process.env.CLIENT_EMAIL,\n      client_id: '',\n      auth_uri: 'https://accounts.google.com/o/oauth2/auth',\n      token_uri: 'https://oauth2.googleapis.com/token',\n      auth_provider_x509_cert_url: 'https://www.googleapis.com/oauth2/v1/certs',\n      client_x509_cert_url: `https://www.googleapis.com/robot/v1/metadata/x509/${process.env.PROJECT_ID}%40appspot.gserviceaccount.com`,\n    },\n  }\n},\n// ...\n```\n\nThe plugin makes the following conversions before feeding Gatsby nodes:\n\n1. Numbers are converted to numbers. Sheets formats numbers as comma-delineated\n   strings, so to determine if something is a number, the plugin tests to see if\n   the string (a) is non-empty and (b) is composed only of commas, decimals, and\n   digits:\n\n```\nif (\n    \"value\".replace(/[,\\.\\d]/g, \"\").length === 0\n      \u0026\u0026 \"value\" !== \"\"\n   ) {\n    ...assume value is a number and handle accordingly\n}\n```\n\n2. \"TRUE\"/\"FALSE\" converted to boolean true/false\n3. empty cells (\"\" in sheets payload) converted to null\n4. Column names are converted to camelcase\n\nA few notes:\n\n1. Not tested with cells of data type dates.\n2. Google sheets mangles column names and converts them all to lower case. This\n   plugin will convert them to camelcase, so the best convention here is to name\n   your columns all lowercase with dashes. e.g. instead of \"Column Name 1\" or\n   \"columnName1\", prefer \"column-name-1\"--this last one will be turned into\n   \"columnName1\" in your GatsbyQL graph.\n\n## Troubleshooting\n\n1. If you get the error \"No key or keyFile set\", make sure you are using a\n   Service Account API key and not a simple API key.\n2. If you get the error \"Cannot read property 'worksheets' of undefined\", make\n   sure you have shared your spreadsheet with your service account user.\n3. If you encounter issues while fetching Spreadsheet data despite your data looks correct, ensure you don't have hidden Sheets in your document which can cause erros.\n\n## Release Process\n\nTo Release a new version of the plugin\n\n1. Bump the version in the `package.json` to the new version\n2. Create a commit message with the pattern `Release 1.2.3` where `1.2.3` is the\n   new version.\n3. push to master\n\n## Author\n\n👤 **Cian Butler \u003cbutlerx@notthe.cloud\u003e**\n\n- Website: https://cianbutler.ie\n- Twitter: [@cianbutlerx](https://twitter.com/cianbutlerx)\n- Github: [@butlerx](https://github.com/butlerx)\n\n## 🤝 Contributing\n\nContributions, issues and feature requests are welcome!\n\nFeel free to check\n[issues page](https://github.com/butlerx/gatsby-source-google-spreadsheets/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc).\n\n## Show your support\n\nGive a ⭐️ if this project helped you!\n\n## 📝 License\n\nCopyright © 2020\n[Cian Butler \u003cbutlerx@notthe.cloud\u003e](https://github.com/butlerc).\n\nThis project is\n[MIT](https://github.com/butlerx/gatsby-source-google-spreadsheets/blob/master/LICENSE)\nlicensed.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbutlerx%2Fgatsby-source-google-spreadsheets","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbutlerx%2Fgatsby-source-google-spreadsheets","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbutlerx%2Fgatsby-source-google-spreadsheets/lists"}