Registry / productivity / google-docs-fetch

google-docs-fetch

JSON →
library0.0.3jsnpmunverified

Fetches a Google Docs document as formatted, inlineable HTML, preserving styles (bold, italics, colors), images, and URLs while stripping page width for reflow. Currently at version 0.0.3 (pre-1.0), this small Node.js library uses a callback-based API and requires the document to be publicly shareable. Key differentiator: simplified extraction of Docs content into HTML without full Google Drive API setup, though limited to public documents.

npm install google-docs-fetch
INSTALL
IMPORT
SIG · GOOGLE-DOCS-FETCH
G
google-docs-fetch
productivityjavascriptv0.0.3
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default (fetch function)
var fetch = require('google-docs-fetch'); fetch('DOCUMENT_ID', function(err, content) { ... });
import fetch from 'google-docs-fetch'; // ESM not supported
Package uses CommonJS (require). No named exports. No TypeScript types.
default (fetch function) as named import
var fetch = require('google-docs-fetch'); fetch('DOCUMENT_ID', function(err, content) { ... });
import { fetch } from 'google-docs-fetch'; // wrong syntax, undefined
Attempting named import fails; always use default import via require.
default (fetch function) with async/await
const fetch = require('google-docs-fetch'); const content = await new Promise((res, rej) => fetch('ID', (err, c) => err ? rej(err) : res(c)));
const fetch = require('google-docs-fetch'); const content = await fetch('ID'); // fetch does not return a promise
Callback-based API; must promisify manually. No promise/async support.

Fetches a publicly shared Google Docs document by ID and logs the resulting HTML with inline CSS.

var fetch = require('google-docs-fetch'); // Replace 'YOUR-DOC-ID' with actual document ID. // Document must be publicly shareable (Anyone with the link can view). fetch('YOUR-DOC-ID', function (err, content) { if (err) { console.error('Error fetching doc:', err); return; } // content is a string containing <style> and <div> HTML console.log(content); });
Debug
Known issues
gotchaDocument must be publicly shareable with 'Anyone with the link' view access.
fix
Change sharing settings in Google Docs to 'Anyone with the link can view'.
affects: >=0
breakingNo ESM or TypeScript support; require() only.
fix
Use CommonJS require; or use dynamic import() if needed, but note package does not export ESM.
affects: >=0
deprecatedCallback-based API: no Promise or async/await support.
fix
Manually promisify the callback (see Problems section for code).
affects: >=0
gotchaDocument ID is case-sensitive; wrong ID returns error without retry.
fix
Verify document ID from the URL (exact match).
affects: >=0
gotchaNo rate limiting or retry logic; rapid successive calls may fail.
fix
Implement your own retry/backoff for multiple fetches.
affects: >=0
Errors
Common errors & fixes
Error: Document not found or access denied
Document ID is incorrect or sharing permissions are not set to public.
fix
Ensure document ID is correct and sharing is set to 'Anyone with the link can view'.
TypeError: fetch is not a function
Using named import (import { fetch } from ...) or ESM import instead of require.
fix
Use CommonJS require: var fetch = require('google-docs-fetch');
TypeError: fetch(...) is not a function (async/await)
Attempting to call fetch as a promise (e.g., await fetch(...)).
fix
Use callback pattern or promisify: const content = await new Promise((res, rej) => fetch(id, (e, c) => e ? rej(e) : res(c)));
ReferenceError: require is not defined (ES modules)
Running in ESM context (e.g., 'type':'module' in package.json) without using createRequire.
fix
Use createRequire from 'module': import { createRequire } from 'module'; const require = createRequire(import.meta.url); const fetch = require('google-docs-fetch');
Upgrade
Version history
0.0.3latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
35 hits · last 30 days
node
32
OpenAI (training)
1
Resources
google-docs-fetch — npm install google-docs-fetch · libregistry