An API that converts Google Sheets into JSON, served by a regular JavaScript function (currently hosted on Coolify (self-hosted)).
Visiting the root URL shows a form where you can paste a Google Sheets link. The form rewrites the link to a valid API URL and redirects you there.
The root page serves public/index.html (with /favicon.ico), and the server
also exposes a simple robots.txt that allows all crawlers.
Requests follow the pattern /SPREADSHEET_ID/sheet_name_or_number. If the sheet
segment is omitted, the request will redirect to the first sheet (/1).
Example:
https://sheet.primehostingdev.xyz/1vufOODlks7O9PGak54hMNP4LWBUAoP-XB9n3VW_aw5Y
This redirects to:
https://sheet.primehostingdev.xyz/1vufOODlks7O9PGak54hMNP4LWBUAoP-XB9n3VW_aw5Y/1
The main request handler lives in functions/opensheet.js. It is a regular
JavaScript function that can run in any compatible runtime.
For local development, run:
npm startThis starts a small Node server from server.js that serves public/index.html
at the root URL and forwards API requests to the handler in
functions/opensheet.js.
The function requires a GOOGLE_API_KEY value using process.env in Node or
Deno.env.get. If the variable is missing, the function responds with an error.
Responses are cached for 30 seconds when a cache API is available (for example,
in edge runtimes that expose caches.default). If the runtime does not support
the cache API, the function skips caching but still returns live data.
npm testTests mock Google Sheets responses to verify rows are returned, ensure the
deployed API returns [{"headline":"It's working!"}], and confirm that
requests missing a sheet segment redirect to the first sheet.
Pull requests to main run npm test via GitHub Actions.
This project is currently hosted on Coolify (self-hosted). Static assets are served from
public, and incoming requests are handled by the function in
functions/opensheet.js.