https://github.com/filipedeschamps/parse-google-docs-json
Authenticates with Google API and parse Google Docs to JSON or Markdown
https://github.com/filipedeschamps/parse-google-docs-json
api google google-docs google-docs-api google-docs-api-format-text json markdown
Last synced: about 1 month ago
JSON representation
Authenticates with Google API and parse Google Docs to JSON or Markdown
- Host: GitHub
- URL: https://github.com/filipedeschamps/parse-google-docs-json
- Owner: filipedeschamps
- License: mit
- Created: 2020-08-19T21:17:26.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2022-03-06T01:07:45.000Z (about 3 years ago)
- Last Synced: 2025-04-10T03:53:48.944Z (about 1 month ago)
- Topics: api, google, google-docs, google-docs-api, google-docs-api-format-text, json, markdown
- Language: JavaScript
- Homepage:
- Size: 36.1 KB
- Stars: 160
- Watchers: 4
- Forks: 18
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Parse Google Docs JSON
This **Node.js** module authenticates with **Google API** and parse **Google Docs** to human-readable **JSON** or **Markdown** without the need to use cumbersome methods like exporting it in HTML via **Google Drive API** and then parse it back to other formats.
# Why
When you use **Google Docs API V1**, the [body](https://developers.google.com/docs/api/reference/rest/v1/documents#Body) that comes with the `documents.get` method is completely fragmented. It's a JSON that you need to recursively parse to get the document into human-readable format. For my luck, there's a Gatsby plugin that internally has this implementation already: [gatsby-source-google-docs](https://github.com/cedricdelpoux/gatsby-source-google-docs). So I've extracted this implementation into this module and exposed it with a **Service Authentication**. For more information about this type of authentication, follow this tutorial: [How to authenticate to any Google API](https://flaviocopes.com/google-api-authentication)
# Warning
This module works like a charm, but it's for personal use, primarily. It will follow semantic version best practices, but will not have any automated tests in the short term.
# How to use
```js
const parseGoogleDocsJson = require("parse-google-docs-json");async function start() {
const parsed = await parseGoogleDocsJson({
documentId: "1ymKw2OGcMfc02XdEEWdy22a_zUAlCxyN3P5Ab4c",
clientEmail: "[email protected]",
privateKey: "-----BEGIN PRIVATE KEY...",
});console.log(parsed.toJson());
console.log(parsed.toMarkdown());
}start();
```# Environment variables
```
clientEmail = process.env.PARSE_GOOGLE_DOCS_CLIENT_EMAIL
privateKey = process.env.PARSE_GOOGLE_DOCS_PRIVATE_KEY
```