UPDATE (May 2019) The Google Docs API was officially launched in February 2019. The documentation is located on the link from my July update below. A few weeks after the launch, I prepared a general overview of the video of what the merge application using the API will look like. (This is not a full episode of the G Suite Dev Show , but a link to a working sample.)
UPDATE (July 2018) The Google Docs team previously announced the upcoming REST API on Google Cloud NEXT '18. Developers interested in gaining access to the early access program for the new API should register at https://developers.google.com/docs . The original answer below remains valid as the REST API will be the second way you can programmatically access Google Docs.
Original answer (March 2017) : (Most of the other answers are deprecated.) Google Docs currently do not have a REST API, however developers can programmatically access documents (CRUDs) using a Google Apps script , server-side JavaScript applications that hosted and run in the Google Cloud. If you're new to application scripting or editing Google Docs with it, here are a few tutorial resources:
- Your first script to create & edit a document and then use Gmail to send it to you.
- I have 4 introductory videos for you (mostly tasteful sheets)
- Useful pages in white papers
- Check out other Google Docs add-ons
A simple example: if you have an existing Doc with the identifier (Drive) of the DOCUMENT_ID_GOES_HERE file, here is how you can basically edit it using the Apps script by doing the pseudo "mail merge" name & send an email to the document with the indicated placeholders {NAME} and {ADDR} :
function mergeNameEmail() { // Open a document by ID var doc = DocumentApp.openById(DOCUMENT_ID_GOES_HERE); // Access the body of the document var body = doc.getBody(); // Merge name & address from template body.replaceText("{NAME}", "Ima Developer"); body.replaceText("{ADDR}", "123 Main St, Anytown, XX 00000"); }
wescpy
source share