Skip to content

Convert Google Sheets or Airtable into a fast REST API with caching. Ideal for MVPs and small projects.

License

Notifications You must be signed in to change notification settings

hamodywe/CacheSheet

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CacheSheet

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!

Features

  • 🚀 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

Installation

Download Binary (Recommended)

Download the latest release for your platform from the releases page.

Build from Source

Make sure you have Go 1.21 or later installed:

git clone https://github.com/hamodywe/CacheSheet.git
cd CacheSheet
go build -o cachesheet

Install via Go

go install github.com/hamodywe/CacheSheet@latest

Usage

Basic Command Structure

cachesheet serve [flags]

Required Flags

  • --provider or -p: Data provider (google-sheets or airtable)
  • --sheet-id or -s: Sheet or table ID

Optional Flags

  • --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")

Environment Variables

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

Examples

Google Sheets

# 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

Airtable

# 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

Short Flags

You can use short flags for convenience:

cachesheet serve -p google-sheets -s 1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms -k your-api-key

API Endpoints

Once the server is running, you can access the following REST API endpoints:

Read Operations

  • GET /health - Health check and server status
  • GET /rows - Get all rows from the cache
  • GET /rows/{id} - Get a specific row by index

Write Operations

  • POST /rows - Add a new row (updates cache immediately, syncs to provider asynchronously)
  • PUT /rows/{id} - Update an existing row by index

Example API Usage

# 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

Setup Instructions

Google Sheets

  1. 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)
  2. Get Sheet ID:

    • Open your Google Sheet
    • Copy the sheet ID from the URL: https://docs.google.com/spreadsheets/d/{SHEET_ID}/edit
  3. Make Sheet Public (or configure OAuth):

    • Click "Share" → "Change to anyone with the link"
    • Or set up proper OAuth credentials for private sheets

Airtable

  1. Get API Key:

  2. Get Base ID:

  3. Get Table Name:

    • Note the name of the table you want to access (visible in Airtable interface)

Development

Project Structure

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

Building

# 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

Running Tests

go test ./...

Development Commands

# 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

Performance Characteristics

  • 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

Contributing

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Make your changes and add tests
  4. Run tests and linting (go test ./... and golangci-lint run)
  5. Commit your changes (git commit -m 'Add some amazing feature')
  6. Push to the branch (git push origin feature/amazing-feature)
  7. Open a Pull Request

License

This project is licensed under the MIT License - see the LICENSE file for details.

Support

Future Improvements

Planned Features

  • 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

Performance Improvements

  • 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

Developer Experience

  • 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

Examples and Use Cases

E-commerce Product Catalog

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

Content Management

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

Configuration Management

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!

About

Convert Google Sheets or Airtable into a fast REST API with caching. Ideal for MVPs and small projects.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages