Using the Google Slides API with Apps Script

The new Google Slides API lets you programmatically create new presentations. You can pull data from external apps, like a Google Spreadsheet or Salesforce CRM, and create a nice-looking report in the form of a presentation. It should also be possible to convert your Google Documents or a markdown formatted text file into a Google presentation.

You can also read an existing presentation using the API and modify individual elements on slides. For instance, if your organization logo has changed, you can use the Google Slides API to update the embedded images inside all slide via the API. Or if you would like to delete all slide that contains specific text, that can be done with the Google Slides API.

The API is in private beta and if you have access, here’s a snippet that shows how to connect to the Google Slides API via Google Apps Script. You would need to enable the API inside Google Cloud Developer Console.

// Fetch all Tables and Shape elements inside the presentation
function googleSlidesAPI(presentationId) {
  var base = "";
  var apiUrl = base + presentationId + "/pages/pageId?fields=pageElements(table,shape)";
  var params = {
    contentType: "application/json",
    headers: {
      "Authorization": "Bearer " + ScriptApp.getOAuthToken()
  // returns a JSON response
  var resp = UrlFetchApp.fetch(apiUrl, params);


Similarly, you can make HTTP POST requests to insert text boxes or images, for replacing text or for deleting specific page elements from slides. To replace text everywhere within a presentation, use a ReplaceAllTextRequest request.