Convert Google Sheets or Airtable into a fast REST API with caching.
CacheSheet is a CLI tool that transforms your spreadsheet data into a high-performance REST API with built-in caching capabilities. No complex backend infrastructure required!
- 🚀 Fast API: Convert spreadsheets to REST APIs instantly
- 💾 Built-in Caching: High-performance in-memory data caching
- 📊 Multiple Providers: Support for Google Sheets and Airtable
- 🔄 Auto-Refresh: Background data synchronization with configurable intervals
- 🛠️ Easy CLI: Simple command-line interface
- 🌐 CORS Support: Ready for browser-based applications
- ✏️ Read/Write Operations: Full CRUD operations with async provider updates
- 📦 Zero Dependencies: Single binary deployment
Download the latest release for your platform from the releases page.
Make sure you have Go 1.21 or later installed:
git clone https://github.com/hamodywe/CacheSheet.git
cd CacheSheet
go build -o cachesheet
go install github.com/hamodywe/CacheSheet@latest
cachesheet serve [flags]
--provider
or-p
: Data provider (google-sheets
orairtable
)--sheet-id
or-s
: Sheet or table ID
--api-key
or-k
: API key for the provider (can also use environment variables)--port
: Port to run the server on (default: 8080)--refresh-interval
: Data refresh interval in minutes (default: 5)--table-name
: Table name for Airtable (default: "Table 1")
You can set API keys via environment variables instead of flags:
export GOOGLE_SHEETS_API_KEY=your-google-api-key
export AIRTABLE_API_KEY=your-airtable-api-key
# Basic usage with Google Sheets
cachesheet serve --provider google-sheets --sheet-id 1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms --api-key your-google-api-key
# With environment variable and custom settings
export GOOGLE_SHEETS_API_KEY=your-google-api-key
cachesheet serve --provider google-sheets --sheet-id 1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms --port 3000 --refresh-interval 10
# Basic usage with Airtable
cachesheet serve --provider airtable --sheet-id appXXXXXXXXXXXXXX --api-key your-airtable-api-key --table-name "My Table"
# With environment variable
export AIRTABLE_API_KEY=your-airtable-api-key
cachesheet serve --provider airtable --sheet-id appXXXXXXXXXXXXXX --table-name "Products" --refresh-interval 2
You can use short flags for convenience:
cachesheet serve -p google-sheets -s 1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms -k your-api-key
Once the server is running, you can access the following REST API endpoints:
GET /health
- Health check and server statusGET /rows
- Get all rows from the cacheGET /rows/{id}
- Get a specific row by index
POST /rows
- Add a new row (updates cache immediately, syncs to provider asynchronously)PUT /rows/{id}
- Update an existing row by index
# Get all rows
curl http://localhost:8080/rows
# Get a specific row
curl http://localhost:8080/rows/0
# Add a new row
curl -X POST http://localhost:8080/rows \
-H "Content-Type: application/json" \
-d '{"name": "John Doe", "email": "[email protected]", "age": "30"}'
# Update a row
curl -X PUT http://localhost:8080/rows/0 \
-H "Content-Type: application/json" \
-d '{"name": "Jane Doe", "email": "[email protected]", "age": "28"}'
# Health check
curl http://localhost:8080/health
-
Enable Google Sheets API:
- Go to the Google Cloud Console
- Create a new project or select an existing one
- Enable the Google Sheets API
- Create credentials (API key)
-
Get Sheet ID:
- Open your Google Sheet
- Copy the sheet ID from the URL:
https://docs.google.com/spreadsheets/d/{SHEET_ID}/edit
-
Make Sheet Public (or configure OAuth):
- Click "Share" → "Change to anyone with the link"
- Or set up proper OAuth credentials for private sheets
-
Get API Key:
- Go to Airtable API documentation
- Sign in and copy your API key
-
Get Base ID:
- Go to Airtable API documentation
- Select your base
- Copy the base ID from the URL or documentation
-
Get Table Name:
- Note the name of the table you want to access (visible in Airtable interface)
CacheSheet/
├── cmd/
│ ├── root.go # Root command definition
│ └── serve.go # Serve subcommand
├── internal/
│ ├── providers/ # Data provider implementations
│ │ ├── googlesheets.go # Google Sheets provider
│ │ └── airtable.go # Airtable provider
│ ├── server/ # HTTP server implementation
│ │ └── server.go # REST API server with chi router
│ └── types/ # Common types and interfaces
│ └── types.go # Provider interface and Row type
├── main.go # Application entry point
├── go.mod # Go module definition
├── .gitignore # Git ignore file
├── LICENSE # MIT license
└── README.md # This file
# Install dependencies
go mod tidy
# Build for current platform
go build -o cachesheet
# Build for multiple platforms
GOOS=linux GOARCH=amd64 go build -o cachesheet-linux-amd64
GOOS=windows GOARCH=amd64 go build -o cachesheet-windows-amd64.exe
GOOS=darwin GOARCH=amd64 go build -o cachesheet-darwin-amd64
GOOS=darwin GOARCH=arm64 go build -o cachesheet-darwin-arm64
go test ./...
# Run with hot reload (install air: go install github.com/cosmtrek/air@latest)
air
# Format code
go fmt ./...
# Vet code
go vet ./...
# Run linter (install golangci-lint)
golangci-lint run
- In-Memory Caching: All data is kept in memory for ultra-fast read operations
- Background Sync: Data is refreshed from the source at configurable intervals
- Async Writes: Write operations update the cache immediately and sync to the provider asynchronously
- CORS Enabled: Ready for use with browser-based applications
- Graceful Shutdown: Proper cleanup on termination signals
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature
) - Make your changes and add tests
- Run tests and linting (
go test ./...
andgolangci-lint run
) - Commit your changes (
git commit -m 'Add some amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- Redis Caching: Optional Redis backend for distributed caching
- Authentication: JWT-based authentication and authorization
- Rate Limiting: Configurable rate limiting for API endpoints
- Multiple Sheets: Support for multiple sheets/tables in a single server instance
- Real-time Sync: WebSocket support for real-time data updates
- Data Validation: Schema validation for incoming data
- Filtering & Pagination: Query parameters for filtering and pagination
- Metrics: Prometheus metrics for monitoring
- Docker Support: Official Docker images
- Kubernetes: Helm charts and Kubernetes manifests
- Configuration File: YAML/JSON configuration file support
- Webhook Support: Configurable webhooks for data changes
- Data Transformation: Built-in data transformation capabilities
- Backup & Restore: Data backup and restore functionality
- Connection Pooling: HTTP client connection pooling
- Compression: Response compression (gzip)
- CDN Support: CDN-friendly caching headers
- Batch Operations: Batch API operations for better performance
- Memory Optimization: Memory usage optimization for large datasets
- CLI Improvements: More CLI commands (validate, test-connection, etc.)
- Better Logging: Structured logging with different log levels
- Health Checks: More comprehensive health check endpoints
- OpenAPI Spec: Auto-generated OpenAPI/Swagger documentation
- Client Libraries: Official client libraries for popular languages
Use Google Sheets or Airtable as your product catalog CMS and CacheSheet as your product API:
# Start server with product data
cachesheet serve --provider airtable --sheet-id appYourBaseID --table-name "Products"
# Your frontend can now fetch products
curl http://localhost:8080/rows
Manage blog posts, articles, or any content in spreadsheets:
# Content management setup
export GOOGLE_SHEETS_API_KEY=your-key
cachesheet serve --provider google-sheets --sheet-id your-sheet-id --refresh-interval 1
Use spreadsheets for application configuration that updates automatically:
# Config service
cachesheet serve --provider google-sheets --sheet-id config-sheet-id --port 9000
CacheSheet transforms your spreadsheets into powerful, fast APIs with minimal setup. Perfect for prototyping, small to medium applications, or as a backend for static sites!