Google Sheets as a Data Source
The gsheets community extension, which this page used to rely on, is not published for DuckDB 2.0.1, the DuckDB version flAPI has embedded since v26.11.23. INSTALL gsheets FROM community fails with HTTP 404 (checked for linux_amd64, osx_arm64 and windows_amd64 on 2026-11-25), and because a failing init stops startup, a config that installs it does not start.
flAPI v26.11.21 was the last release on DuckDB 1.5, where gsheets is published; it does not get the fixes of later releases. Check the community extension list before you plan on it.
A spreadsheet is the data store many teams already use: marketing keeps product copy in it, support keeps the FAQ, a Google Form fills one with sign-ups. Serving it as an API lets an app or an agent read that data without anyone copying it into a database.
What works today: read a CSV export
A Google Sheet can be downloaded as CSV over HTTPS, and flAPI reads CSV over HTTPS with httpfs, which is in its default extension set. For a sheet whose sharing setting is "anyone with the link can view", the export URL is:
https://docs.google.com/spreadsheets/d/<SPREADSHEET_ID>/export?format=csv&gid=<SHEET_GID>
<SHEET_GID> is the number after gid= in the browser address bar when that tab is open.
project-name: sheets-api
template:
path: ./sqls
connections:
products-sheet:
properties:
url: 'https://docs.google.com/spreadsheets/d/1A2B3C4D5E6F7G8H9I0J/export?format=csv&gid=0'
ducklake:
enabled: true
alias: cache
metadata-path: ./cache.ducklake
data-path: ./cache_data
url-path: /products
request:
- field-name: category
field-in: query
required: false
validators:
- type: enum
allowedValues: [Electronics, Clothing, Books, Home]
- field-name: max_price
field-in: query
required: false
validators:
- type: number
min: 0
template-source: products.sql
connection: [products-sheet]
cache:
enabled: true
table: products_cache
schedule: 10m
template-file: products_cache.sql
CREATE OR REPLACE TABLE {{cache.catalog}}.{{cache.schema}}.{{cache.table}} AS
SELECT product_id, name, category, CAST(price AS DOUBLE) AS price, in_stock
FROM read_csv('{{{ conn.url }}}', header = true)
SELECT *
FROM {{cache.catalog}}.{{cache.schema}}.{{cache.table}}
WHERE ({{ params.max_price }} IS NULL OR price <= {{ params.max_price }})
{{#params.category}}
AND category = '{{{ params.category }}}'
{{/params.category}}
ORDER BY name
- Not tested against a live sheet. The export URL is Google's, and its behaviour is theirs; check it with
curl -L '<url>'first. - Anyone with the link can read the sheet. Use this only for data that may be public. For private sheets, export them to a bucket from Google Apps Script or a scheduled job and read that file with credentials (Cloud Storage).
- Cache it. Each live request would download the whole sheet again. With the cache, a refresh downloads it once per
schedule, and requests read the local copy. {{{ conn.url }}}uses triple braces: double braces would HTML-escape&and/in the URL.
When gsheets is published for DuckDB 2.0.1
The extension reads a sheet with read_gsheet(spreadsheet, sheet = ..., range = ..., header = ..., all_varchar = ...) and authenticates with a gsheet secret. With flAPI the setup would be:
template:
path: ./sqls
environment-whitelist:
- '^GOOGLE_SHEETS_TOKEN$'
connections:
products-sheet:
init: |
INSTALL gsheets FROM community;
LOAD gsheets;
CREATE OR REPLACE SECRET sheets (TYPE gsheet, PROVIDER access_token,
TOKEN '{{env.GOOGLE_SHEETS_TOKEN}}');
properties:
spreadsheet_id: '1A2B3C4D5E6F7G8H9I0J'
CREATE OR REPLACE TABLE {{cache.catalog}}.{{cache.schema}}.{{cache.table}} AS
SELECT * FROM read_gsheet('{{{ conn.spreadsheet_id }}}', sheet = 'Products')
- A server cannot complete the browser OAuth flow that
CREATE SECRET (TYPE gsheet)without a token starts; use a token. - Access tokens expire, and
initruns only at startup, so the secret is not renewed while the server runs. Plan for restarts, or for the export approach above. initis not a template:{{ conn.* }}is not rendered there, and only whitelisted{{env.NAME}}references are substituted.${VAR}is not supported.- Use
CREATE SECRET, notCREATE PERSISTENT SECRET, which writes the token to~/.duckdb/stored_secrets.
Limits of a spreadsheet
| Limitation | Impact | Workaround |
|---|---|---|
| Google API rate limits | Live reads get throttled | Serve from a cache |
| Size limit per spreadsheet | Large datasets do not fit | Split, or move to a database |
| No transactions | Concurrent edits can race | Append-only patterns, one editor per tab |
| Loose types | A text cell in a number column breaks a cast | all_varchar / read_csv(..., all_varchar = true), then cast explicitly |
When to use, when to avoid
Use a sheet when: a non-technical team owns the data, the data is small (thousands of rows), it changes a few times a day at most, and minutes of staleness are fine.
Avoid it when: you need high-frequency writes, more than about 100,000 rows, transactions, or relational queries across many tabs.
Migration path
Start with a sheet and move to a database later. Because requests read only the cache table, moving changes only the populate template:
-- Phase 1: the sheet's CSV export
CREATE OR REPLACE TABLE {{cache.catalog}}.{{cache.schema}}.{{cache.table}} AS
SELECT * FROM read_csv('{{{ conn.url }}}', header = true);
-- Phase 2: PostgreSQL, attached in init as pg (see the PostgreSQL guide)
CREATE OR REPLACE TABLE {{cache.catalog}}.{{cache.schema}}.{{cache.table}} AS
SELECT * FROM pg.public.products;
The endpoint, its validators and its serving template stay the same.
Next steps
- Caching Setup: essential for any sheet
- Cloud Storage: read exported files from a private bucket
- PostgreSQL: when you outgrow the sheet
- Connections Overview: which sources work with DuckDB 2.0.1