קל לארגן דפים בעזרת אוספים
אפשר לשמור ולסווג תוכן על סמך ההעדפות שלך.
Google Slides API מאפשר לקרוא נתונים של מצגות, דפים ורכיבי דפים. בדוגמאות שבדף הזה מוסבר איך לבצע פעולות קריאה נפוצות באמצעות השיטות presentations.get ו-presentations.pages.get.
בדוגמאות האלה נעשה שימוש בערכי ה-placeholder הבאים:
PRESENTATION_ID—מציין איפה מספקים את מזהה המצגת. אפשר למצוא את הערך של המזהה הזה בכתובת ה-URL של המצגת.
PAGE_ID – מציין איפה מציינים את המזהה של אובייקט הדף. אפשר לאחזר את הערך של המאפיין הזה מכתובת ה-URL או באמצעות בקשת קריאה של API.
הדוגמאות האלה מוצגות כבקשות HTTP כדי שלא יהיו תלויות בשפה. הדוגמאות מבוססות על מצגת לדוגמה, שבה 1EAYk18WDjIG-zp_0vLm3CsfQh_i8eXc67Jo2O9C6Vuc הוא PRESENTATION_ID. PAGE_ID של השקף הראשון במצגת הזו הוא ge63a4b4_1_0.
בדוגמאות שבהמשך נעשה שימוש במסכות שדות כדי להחזיר רק מידע ספציפי על המצגת, השקף והרכיב בדף. שימוש במסכות שדות משפר גם את הביצועים.
קריאת מזהי אובייקטים בשקף
בדוגמת הקוד הבאה presentations.get מוצג איך לאחזר רשימה של כל מזהי האובייקטים של השקפים מהמצגת. המזהים מוחזרים לפי הסדר של השקפים במצגת, ואפשר להשתמש בהם כדי לציין שקפים ספציפיים בבקשות API הבאות. אפשר לאתר את מזהי האובייקטים של דפי התבנית ודפי הפריסה באותו אופן, באמצעות fields=masters.objectId ו-fields=layout.objectId.
זהו פרוטוקול הבקשה לקריאת מזהי אובייקטים של שקפים:
GET https://slides.googleapis.com/v1/presentations/PRESENTATION_ID?fields=slides.objectId
התגובה מורכבת מאובייקט Presentation שמכיל את מזהי האובייקטים שביקשתם:
בדוגמת הקוד הבאה של presentations.pages.get מוצג איך לאחזר רשימה של כל Shapes בדף. אפשר לאחזר סוגים אחרים של PageElement על ידי ציון שלהם באמצעות הפרמטר fields. לדוגמה,
fields=pageElements(line,table) מחזירה רק מידע על
line ועל
table
מרכיבי דף, אם יש כאלה בדף.
הפרוטוקול הבא הוא פרוטוקול הבקשה לקריאת רכיבי צורה מדף:
GET https://slides.googleapis.com/v1/presentations/PRESENTATION_ID/pages/PAGE_ID?fields=pageElements.shape
התשובה מורכבת מאובייקט Page שמכיל את רכיבי הצורה המבוקשים. הסוגריים המסולסלים הריקים מציינים רכיבים בדף שלא תואמים לסוג הצורה. במקרה הזה, אלה רכיבים של תמונות בדף.
[[["התוכן קל להבנה","easyToUnderstand","thumb-up"],["התוכן עזר לי לפתור בעיה","solvedMyProblem","thumb-up"],["סיבה אחרת","otherUp","thumb-up"]],[["חסרים לי מידע או פרטים","missingTheInformationINeed","thumb-down"],["התוכן מורכב מדי או עם יותר מדי שלבים","tooComplicatedTooManySteps","thumb-down"],["התוכן לא עדכני","outOfDate","thumb-down"],["בעיה בתרגום","translationIssue","thumb-down"],["בעיה בדוגמאות/בקוד","samplesCodeIssue","thumb-down"],["סיבה אחרת","otherDown","thumb-down"]],["עדכון אחרון: 2025-08-29 (שעון UTC)."],[],[],null,["# Basic reading\n\nThe Google Slides API lets you read presentation, page, and page element data. The\nexamples on this page show how to perform common read operations using both the\n[`presentations.get`](/workspace/slides/api/reference/rest/v1/presentations/get) and\n[`presentations.pages.get`](/workspace/slides/api/reference/rest/v1/presentations.pages/get)\nmethods.\n\nThese examples use the following placeholders:\n\n- \u003cvar translate=\"no\"\u003ePRESENTATION_ID\u003c/var\u003e---Indicates where you provide the [presentation\n ID](/workspace/slides/api/guides/overview#the_structure_of_a_presentation). You can discover the value for this ID from the presentation URL.\n- \u003cvar translate=\"no\"\u003ePAGE_ID\u003c/var\u003e---Indicates where you provide the [page object\n ID](/workspace/slides/api/guides/overview#working_with_object_ids). You can retrieve the value for this from the URL or by using an API read request.\n\nThese examples are presented as HTTP requests to be language neutral. The\nexamples read from this [example\npresentation](https://docs.google.com/presentation/d/1EAYk18WDjIG-zp_0vLm3CsfQh_i8eXc67Jo2O9C6Vuc/edit),\nthat has `1EAYk18WDjIG-zp_0vLm3CsfQh_i8eXc67Jo2O9C6Vuc` as its\n\u003cvar translate=\"no\"\u003ePRESENTATION_ID\u003c/var\u003e. The \u003cvar translate=\"no\"\u003ePAGE_ID\u003c/var\u003e of the\n[first\nslide](https://docs.google.com/presentation/d/1EAYk18WDjIG-zp_0vLm3CsfQh_i8eXc67Jo2O9C6Vuc/edit#slide=id.ge63a4b4_1_0)\nin this presentation is `ge63a4b4_1_0`.\n\nThe examples here use [field masks](/workspace/slides/api/guides/field-masks) to only\nreturn specific requested information about the presentation, slide, and page\nelement. Using field masks also improves performance.\n\nRead slide object IDs\n---------------------\n\nThe following\n[`presentations.get`](/workspace/slides/api/reference/rest/v1/presentations/get) code\nsample shows how to retrieve a list of all the slide object IDs from the\npresentation. The IDs are returned in the slide presentation order, and can be\nused to indicate specific slides in subsequent API requests. You can get the\nobject IDs of master and layout pages the same way, using\n`fields=masters.objectId` and `fields=layout.objectId`.\n\nThe following is the request protocol to read slide object IDs:\n\n\u003cbr /\u003e\n\n```\nGET https://slides.googleapis.com/v1/presentations/PRESENTATION_ID?fields=slides.objectId\n```\n\nThe response consists of a\n[`Presentation`](/workspace/slides/api/reference/rest/v1/presentations#resource:-presentation)\nobject containing the object IDs requested: \n\n```scdoc\n{\n \"slides\": [\n {\n \"objectId\": \"ge63a4b4_1_0\"\n },\n {\n \"objectId\": \"ge63a4b4_1_9\"\n },\n {\n \"objectId\": \"ge63a4b4_1_23\"\n },\n {\n \"objectId\": \"ge63a4b4_1_35\"\n },\n {\n \"objectId\": \"ge63a4b4_1_43\"\n }\n ]\n}\n```\n\nRead element object IDs from a page\n-----------------------------------\n\nThe following\n[`presentations.pages.get`](/workspace/slides/api/reference/rest/v1/presentations.pages/get)\ncode sample shows how to retrieve a list of object IDs for all the page elements\non a page.\n\nThe following is the request protocol to read element object IDs from a page:\n\n\u003cbr /\u003e\n\n```\nGET https://slides.googleapis.com/v1/presentations/PRESENTATION_ID/pages/PAGE_ID?fields=pageElements.objectId\n```\n\nThe response consists of a\n[`Page`](/workspace/slides/api/reference/rest/v1/presentations.pages#resource-page) object\ncontaining the object IDs requested: \n\n```scdoc\n{\n \"pageElements\": [\n {\n \"objectId\": \"ge63a4b4_1_5\"\n },\n {\n \"objectId\": \"ge63a4b4_1_6\"\n },\n {\n \"objectId\": \"ge63a4b4_1_7\"\n },\n {\n \"objectId\": \"ge63a4b4_1_8\"\n }\n ]\n}\n```\n\nRead shape elements from a page\n-------------------------------\n\nThe following\n[`presentations.pages.get`](/workspace/slides/api/reference/rest/v1/presentations.pages/get)\ncode sample shows how to retrieve a list of all\n[`Shapes`](/workspace/slides/api/reference/rest/v1/presentations.pages/shapes#Page.Shape/)\non a page. You can retrieve other\n[`PageElement`](/workspace/slides/api/reference/rest/v1/presentations.pages#Page.PageElement)\nkinds by specifying them using the `fields` parameter. For example,\n`fields=pageElements(line,table)` only returns information about\n[`line`](/workspace/slides/api/reference/rest/v1/presentations.pages/lines#Page.Line) and\n[`table`](/workspace/slides/api/reference/rest/v1/presentations.pages/tables#Page.Table)\npage elements, if any are present on the page.\n| The Slides API [`presentations.pages.get`](/workspace/slides/api/reference/rest/v1/presentations.pages/get) request can return every property a shape has, including ones the API can't edit.\n\nThe following is the request protocol to read shape elements from a page:\n\n\u003cbr /\u003e\n\n```\nGET https://slides.googleapis.com/v1/presentations/PRESENTATION_ID/pages/PAGE_ID?fields=pageElements.shape\n```\n\nThe response consists of a\n[`Page`](/workspace/slides/api/reference/rest/v1/presentations.pages#resource-page) object\ncontaining the shape elements requested. The empty braces indicate page elements\nthat are not of the shape type; in this case, they're image page elements. \n\n```carbon\n{\n \"/workspace/slides/api/reference/rest/v1/presentations.pages#Page.PageElement\": [\n {},\n {},\n {\n \"/workspace/slides/api/reference/rest/v1/presentations.pages/shapes#Page.Shape/\": {\n \"/workspace/slides/api/reference/rest/v1/presentations.pages/shapes#Page.ShapeProperties\" {\n \"/workspace/slides/api/reference/rest/v1/presentations.pages/other#Page.Outline\" {\n \"/workspace/slides/api/reference/rest/v1/presentations.pages/other#Page.DashStyle\": \"SOLID\",\n \"/workspace/slides/api/reference/rest/v1/presentations.pages/other#Page.OutlineFill\": {\n \"/workspace/slides/api/reference/rest/v1/presentations.pages/other#Page.SolidFill\": {\n \"alpha\": 1,\n \"/workspace/slides/api/reference/rest/v1/presentations.pages/other#Page.OpaqueColor\": {\n \"/workspace/slides/api/reference/rest/v1/presentations.pages/other#Page.RgbColor\": {}\n }\n },\n },\n \"/workspace/slides/api/reference/rest/v1/presentations.pages/other#Page.PropertyState\": \"NOT_RENDERED\",\n \"/workspace/slides/api/reference/rest/v1/Dimension\": {\n \"magnitude\": 9525,\n \"/workspace/slides/api/reference/rest/v1/Unit\": \"EMU\"\n }\n },\n \"/workspace/slides/api/reference/rest/v1/presentations.pages/other#Page.Shadow\": {\n \"/workspace/slides/api/reference/rest/v1/presentations.pages/other#Page.RectanglePosition\": \"BOTTOM_LEFT\",\n \"alpha\": 1,\n \"/workspace/slides/api/reference/rest/v1/Dimension\": {\n \"/workspace/slides/api/reference/rest/v1/Unit\": \"EMU\"\n },\n \"/workspace/slides/api/reference/rest/v1/presentations.pages/other#Page.OpaqueColor\": {\n \"/workspace/slides/api/reference/rest/v1/presentations.pages/other#Page.RgbColor\": {}\n },\n \"/workspace/slides/api/reference/rest/v1/presentations.pages/other#Page.PropertyState\": \"NOT_RENDERED\",\n \"rotateWithShape\": false,\n \"/workspace/slides/api/reference/rest/v1/presentations.pages/other#Page.AffineTransform\": {\n \"scaleX\": 1,\n \"scaleY\": 1,\n \"/workspace/slides/api/reference/rest/v1/Unit\": \"EMU\"\n },\n \"/workspace/slides/api/reference/rest/v1/presentations.pages/shapes#Page.Type_2\": \"OUTER\"\n },\n \"/workspace/slides/api/reference/rest/v1/presentations.pages/shapes#Page.ShapeBackgroundFill\" : {\n \"/workspace/slides/api/reference/rest/v1/presentations.pages/other#Page.PropertyState\": \"NOT_RENDERED\",\n \"/workspace/slides/api/reference/rest/v1/presentations.pages/other#Page.SolidFill\": {\n \"alpha\": 1,\n \"/workspace/slides/api/reference/rest/v1/presentations.pages/other#Page.OpaqueColor\": {\n \"/workspace/slides/api/reference/rest/v1/presentations.pages/other#Page.RgbColor: {\n \"blue\": 1,\n \"green\": 1,\n \"red\": 1\n }\n }\n }\n }\n },\n \"shapeType\": \"TEXT_BOX\",\n \"text\": {\n \"textElements\": [\n {\n \"endIndex\": 11,\n \"paragraphMarker\": {\n \"style\": {\n \"alignment\": \"START\",\n \"direction\": \"LEFT_TO_RIGHT\",\n \"indentEnd\": {\n \"unit\": \"PT\"\n },\n \"indentFirstLine\": {\n \"unit\": \"PT\"\n },\n \"indentStart\": {\n \"unit\": \"PT\"\n },\n \"lineSpacing\": 100,\n \"spaceAbove\": {\n \"unit\": \"PT\"\n },\n \"spaceBelow\": {\n \"unit\": \"PT\"\n },\n \"spacingMode\": \"COLLAPSE_LISTS\"\n }\n }\n },\n {\n \"endIndex\": 11,\n \"textRun\": {\n \"content\": \"Baby Album\\n\",\n \"style\": {\n \"backgroundColor\": {},\n \"baselineOffset\": \"NONE\",\n \"bold\": false,\n \"fontFamily\": \"Arial\",\n \"fontSize\": {\n \"magnitude\": 14,\n \"unit\": \"PT\"\n },\n \"foregroundColor\": {\n \"opaqueColor\": {\n \"rgbColor\": {}\n }\n },\n \"italic\": false,\n \"smallCaps\": false,\n \"strikethrough\": false,\n \"underline\": false\n }\n }\n }\n ]\n }\n }\n },\n ...\n ]\n}\n```"]]