The Slides API lets you read presentation, page, and page element data. The examples on this page show how to perform common read operations using the presentations.get and presentations.pages.get methods.
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.
These examples read from this example presentation,
which has 1EAYk18WDjIG-zp_0vLm3CsfQh_i8eXc67Jo2O9C6Vuc
as its
presentationId. The pageId of the
first slide
in this presentation is ge63a4b4_1_0
.
The examples here use field masks to only return specific requested information about the presentation, slides and page elements. Using field masks this way improves performance.
Read slide object IDs
The following presentations.get
request retrieves a list of all the slide object IDs from the presentation.
The IDs are returned in the slide presentation order, and can be used to
indicate specific slides in subsequent API requests. You can get the
object IDs of master and layout pages the same way, using
fields=masters.objectId
and fields=layout.objectId
.
GET https://slides.googleapis.com/v1/presentations/presentationId?fields=slides.objectId
The response to this method call is a Presentation
object containing the components requested:
{ "slides": [ { "objectId": "ge63a4b4_1_0" }, { "objectId": "ge63a4b4_1_9" }, { "objectId": "ge63a4b4_1_23" }, { "objectId": "ge63a4b4_1_35" }, { "objectId": "ge63a4b4_1_43" } ] }
Read element object IDs from a page
The following presentations.pages.get request retrieves a list of object IDs for all the page elements on a page.
GET https://slides.googleapis.com/v1/presentations/presentationId/pages/pageId?fields=pageElements.objectId
The response to this method call is a Page
object containing the components requested:
{ "pageElements": [ { "objectId": "ge63a4b4_1_5" }, { "objectId": "ge63a4b4_1_6" }, { "objectId": "ge63a4b4_1_7" }, { "objectId": "ge63a4b4_1_8" } ] }
Read shape elements from a page
The following
presentations.pages.get
request retrieves a list of all
shape elements
on a page. You can retrieve other
page element kinds
by specifying them using the fields
parameter. For example,
fields=pageElements(line,table)
only returns information about
line
and table
page elements, if any are present on the page.
The request protocol for this example is shown below.
GET https://slides.googleapis.com/v1/presentations/presentationId/pages/pageId?fields=pageElements.shape
The response to this method call is a Page
object containing the components requested. The empty braces indicate page
elements that are not of the shape type; in this case, they are image page
elements.
{ "pageElements": [ {}, {}, { "shape": { "shapeProperties" { "outline" { "dashStyle": "SOLID", "outlineFill": { "solidFill": { "alpha": 1, "color": { "rgbColor": {} } }, }, "propertyState": "NOT_RENDERED", "weight": { "magnitude": 9525, "unit": "EMU" } }, "shadow": { "alignment": "BOTTOM_LEFT", "alpha": 1, "blurRadius": { "unit": "EMU" }, "color": { "rgbColor": {} }, "propertyState": "NOT_RENDERED", "rotateWithShape": false, "transform": { "scaleX": 1, "scaleY": 1, "unit": "EMU" }, "type": "OUTER" }, "shapeBackgroundFill" : { "propertyState": "NOT_RENDERED", "solidFill": { "alpha": 1, "color": { "rgbColor: { "blue": 1, "green": 1, "red": 1 } } } } }, "shapeType": "TEXT_BOX", "text": { "textElements": [ { "endIndex": 11, "paragraphMarker": { "style": { "alignment": "START", "direction": "LEFT_TO_RIGHT", "indentEnd": { "unit": "PT" }, "indentFirstLine": { "unit": "PT" }, "indentStart": { "unit": "PT" }, "lineSpacing": 100, "spaceAbove": { "unit": "PT" }, "spaceBelow": { "unit": "PT" }, "spacingMode": "COLLAPSE_LISTS" } } }, { "endIndex": 11, "textRun": { "content": "Baby Album\n", "style": { "backgroundColor": {}, "baselineOffset": "NONE", "bold": false, "fontFamily": "Arial", "fontSize": { "magnitude": 14, "unit": "PT" }, "foregroundColor": { "opaqueColor": { "rgbColor": {} } }, "italic": false, "smallCaps": false, "strikethrough": false, "underline": false } } } ] } } }, ... ] }