💡 Summary
A RESTful API service that uses Google Sheets as a lightweight database for CRUD operations.
🎯 Target Audience
🤖 AI Roast: “Powerful, but the setup might scare off the impatient.”
Risk: Medium. Review: shell/CLI command execution; outbound network access (SSRF, data egress); filesystem read/write scope and path traversal; dependency pinning and supply-chain risk. Run with least privilege and audit before enabling in production.
GSheet-CRUD
A Google Sheets RESTful API service based on sheetsql, using Google Sheets as a database with full CRUD operations.
Features
- Use Google Sheets as a lightweight database
- Standard RESTful API (GET/POST/PUT/DELETE)
- Support query parameters for data filtering
- Built with Next.js, supports one-click deployment to Vercel
Prerequisites
1. Share Google Sheets Permission
Important: You must add the following service account email as an Editor to your Google Sheets, otherwise reading and writing data will not work:
gsheett-younami@woven-fountain-458301-p7.iam.gserviceaccount.com
Steps:
- Open your Google Sheets document
- Click the "Share" button in the top right corner
- Paste the above email address in the "Add people" input field
- Set the permission to "Editor"
- Click "Done"
2. Prepare Sheet Data
- The first row of the sheet must be column names (field names)
- Data starts from the second row
Example sheet structure:
| name | age | email | |------|-----|-------| | John | 25 | john@example.com | | Jane | 30 | jane@example.com |
API Usage
URL Format
/{doc_id}/{sheet_name}
doc_id: Google Sheets document ID (can be found in the URL:https://docs.google.com/spreadsheets/d/{doc_id}/edit)sheet_name: Sheet name (optional, defaults toSheet1)
Query Data (GET)
Get all data:
GET /{doc_id}/{sheet_name}
Query with conditions:
GET /{doc_id}/{sheet_name}?name=John&age=25
Insert Data (POST)
Insert a single record:
POST /{doc_id}/{sheet_name} Content-Type: application/json { "name": "Mike", "age": 28, "email": "mike@example.com" }
Insert multiple records:
POST /{doc_id}/{sheet_name} Content-Type: application/json [ {"name": "Mike", "age": 28, "email": "mike@example.com"}, {"name": "Sarah", "age": 35, "email": "sarah@example.com"} ]
Update Data (PUT)
Match data to update using query parameters:
PUT /{doc_id}/{sheet_name}?name=John Content-Type: application/json { "age": 26, "email": "new_email@example.com" }
Delete Data (DELETE)
Match data to delete using query parameters:
DELETE /{doc_id}/{sheet_name}?name=John
Local Development
Install Dependencies
npm install # or yarn install
Configure Service Account
Save the Google Cloud service account JSON key file as google-serviceaccount.json in the project root directory.
Start Development Server
npm run dev # or yarn dev
The service will start at http://localhost:3000.
Deployment
Deploy to Vercel (Recommended)
- Push the project to GitHub
- Import the project in Vercel
- Add environment variable in project settings under "Environment Variables":
- Name:
GOOGLE_SERVICE_ACCOUNT_CREDENTIALS - Value: Paste the complete contents of
google-serviceaccount.jsonfile
- Name:
- Click Deploy
Other Deployment Methods
Build for production:
npm run build
Start production server:
npm run start
Note: When deploying in non-Vercel environments, ensure you configure the service account credentials using one of these methods:
- Set environment variable
GOOGLE_SERVICE_ACCOUNT_CREDENTIALS(value is the JSON file content) - Or place the
google-serviceaccount.jsonfile in the project root directory
Tech Stack
- Next.js - React full-stack framework
- sheetsql - Google Sheets database operation library
- qs - URL query string parsing
Related Links
License
MIT
Pros
- Easy to set up and use with Google Sheets
- Supports standard RESTful API operations
- Lightweight and cost-effective solution
Cons
- Limited scalability for larger datasets
- Dependent on Google Sheets' performance
- Requires proper configuration of service accounts
Related Skills
pytorch
S“It's the Swiss Army knife of deep learning, but good luck figuring out which of the 47 installation methods is the one that won't break your system.”
agno
S“It promises to be the Kubernetes for agents, but let's see if developers have the patience to learn yet another orchestration layer.”
nuxt-skills
S“It's essentially a well-organized cheat sheet that turns your AI assistant into a Nuxt framework parrot.”
Disclaimer: This content is sourced from GitHub open source projects for display and rating purposes only.
Copyright belongs to the original author vkboo.
