← All guides

How do I use Google Sheets as an API in Node.js?

Quick answer

With SheetZAPI, you skip the OAuth flow entirely. Connect your sheet in the dashboard, then fetch your data in Node.js with a single fetch() call and your API key in the X-API-Key header. No googleapis package, no service account JSON files, no token refresh logic.

The standard approach: googleapis (complex)

The official Node.js path requires installing the googleapis package, creating a Google Cloud project, generating a service account JSON credential file, loading it at runtime, calling google.auth.GoogleAuth to get a client, then calling sheets.spreadsheets.values.get() with a range like "Sheet1!A1:Z". The response is a nested array of cell values, not JSON objects — you map it manually. That's 50+ lines before you see a single row.

The SheetZAPI approach: one fetch call

With SheetZAPI, your Node.js code is three lines: import fetch (built-in since Node 18), call GET /api/v1/d/{sheetId}/rows with your X-API-Key header, and await the JSON. You get an array of objects keyed by your header row — no mapping required. Add ?_filter=status:eq:active or ?_sort=-createdAt to filter and sort without writing any query logic.

Filtering and pagination in Node.js

SheetZAPI supports URL query parameters for all filtering needs. In Node.js: const url = new URL('https://api.sheetzapi.com/api/v1/d/{id}/rows'); url.searchParams.set('_filter', 'price:gte:10'); url.searchParams.set('_limit', '25'); url.searchParams.set('_offset', '0'). Operators include eq, ne, gt, lt, gte, lte, contains, startswith, and in.

Writing data back to your sheet

POST to /rows with a JSON body to append a new row. PATCH /rows/:rowNumber with a partial object to update specific fields. DELETE /rows/:rowNumber to remove a row. All operations use the same API key and return the updated row object. No Google OAuth write scopes required.

Frequently asked questions

How do I read Google Sheets in Node.js without googleapis?

Use SheetZAPI. Connect your sheet, then fetch from https://api.sheetzapi.com/api/v1/d/{sheetId}/rows with an X-API-Key header. You get clean JSON rows without any googleapis setup.

Do I need a Google Cloud project to use Google Sheets in Node.js?

Not with SheetZAPI. You share your sheet with SheetZAPI's service account once, and all Google Cloud setup is handled on our end. Your Node.js code only needs your SheetZAPI API key.

How do I write to a Google Sheet from Node.js?

POST to /api/v1/d/{sheetId}/rows with a JSON body. SheetZAPI appends the row to your sheet automatically. No googleapis write scope or OAuth consent required.

Is there a Node.js SDK for SheetZAPI?

Any HTTP client works — native fetch (Node 18+), axios, or got. The API is standard REST with JSON, so no SDK is needed.

Start reading your Google Sheet in Node.js — free

Get Started Free