Authentication Modes
GViz Mode (Google Visualization API)
Zero-config, SQL-like querying for public Google Sheets without API keys.
Google Visualization API mode (gviz) enables zero-config Read-Only querying for public Google Sheets without requiring Google API Keys or GCP accounts.
It supports Google Query Language (SQL-like filtering, column selection, sorting, and aggregations).
Setup
- Open your Google Sheet -> Click Share -> Change access to Anyone with the link can view.
- Copy the Spreadsheet ID from the browser URL:
https://docs.google.com/spreadsheets/d/1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms/edit - Add to
.env:
.env
GSHEET_SPREADSHEET_ID=1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms
SQL Query Example
pages/products.vue
<script setup lang="ts">
// Select columns A, B, C where price (Col C) > 50 sorted descending
const { data: topProducts } = await useGSheetAsObject('A1:C100', {
sheet: 'products',
query: 'SELECT A, B, C WHERE C > 50 ORDER BY C DESC'
})
</script>