Presentation Operations

The Slides API allows you to manage existing presentation files and create new ones. The examples on this page show some common presentation operations that can be achieved with the API.

These examples use the following variables:

  • presentationId — indicates where you provide the presentation ID. You can discover the value for this ID from the presentation URL.
  • pageId — indicates where you provide the page object ID. You can retrieve the value for this from the URL or by using an API read request.
  • pageElementId — indicates where you provide the page element object ID. You can specify this ID for elements you create (with some restrictions) or allow the API to automatically create one; element IDs can be retrieved through an API read request.

Create a new presentation

The following presentations.create request creates a new, blank presentation file entitled "My New Presentation". It is also possible to create blank presentation files using the Drive API Files.create method, by specifying application/vnd.google-apps.presentation as the mimeType.

The request protocol is shown below. The Create and Manage Presentations guide shows an example that implements a batch update in different languages using the Google API client libraries.

POST https://slides.googleapis.com/v1/presentations
{
  "title": "My New Presentation"
}

List existing presentation files

The Slides API does not provide a method for retrieving list of presentations, but this can be done easily with the Drive API. The Drive API Files.list request presented here uses field masks to return a list of presentation files in your Drive, with the file IDs, titles, and a link.

The request protocol is shown below. The Drive API Search for Files guide shows an example that implements a file search request in different languages using the Google API client libraries.

GET https://www.googleapis.com/drive/v3/files?q="mimeType=application/vnd.google-apps.presentation"&fields=files(id,name,webViewLink)

The response to this request has the following structure:

{
 "files": [
    {
     "id": "abcdefghijklmnopqrstuvwxyz0123456789",
     "name": "Project Vision",
     "webViewLink": "https://docs.google.com/a/google.com/presentation/d/abcdefghijklmnopqrstuvwxyz0123456789/edit?usp=drivesdk"
    },
    {
     "id": "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789",
     "name": "Untitled Presentation",
     "webViewLink": "https://docs.google.com/a/google.com/presentation/d/ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789/edit?usp=drivesdk"
    },
    ...
  ]
}

Replace text throughout a presentation

The following presentations.batchUpdate request replaces text throughout the presentation specfied by presentationId. Every instance of the string "Gizmo Corp." is replaced with the text "Gadget Inc." This includes text in text boxes and other shapes, on slides and masters. In this instance, the text replacement is case-sensitive.

The request protocol is shown below. The Merge Data into Slides guide shows an example that implements a batch update in different languages using the Google API client libraries.

POST https://slides.googleapis.com/v1/presentations/presentationId:batchUpdate
{
  "requests": [
    {
      "replaceAllText": {
          "containsText": {
            "text": "Gizmo Corp.",
            "matchCase": true
          },
          "replaceText": "Gadget Inc."
      }
    }
  ]
}

Send feedback about...

Need help? Visit our support page.