示例
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
本部分提供了一组示例应用和“配方”示例,演示了如何将预期的 Google Slides 操作转换为 Google Slides API 请求。
Codelab

幻灯片 Codelab 介绍了如何使用 Google Slides API 作为自定义演示工具来分析最常见的软件许可。
您将学习如何使用 BigQuery 查询 GitHub 上的所有开源代码,以及如何使用 Slides API 创建幻灯片演示文稿来展示结果。
示例应用

借助 Markdown to Slides 命令行工具,您可以根据 Markdown 文件生成幻灯片演示。
您可以使用此代码库探索 Slides API,也可以派生该代码库并修改代码,以便为 JavaScript 应用提供 Slides 输出。
食谱
本部分列出的示例演示了如何将 Slides 中的常见操作表示为 Slides API 请求。
这些示例以 HTTP 请求的形式呈现,不涉及具体语言。如需了解如何使用 Google API 客户端库以特定语言实现 Slides API 请求协议,请参阅以下指南:
本部分中的食谱分为以下几类:
- 基本读取 - 显示从演示文稿读取信息的常用方法的示例。
- 基本写入 - 显示向演示文稿写入数据的常见方法的示例。
- 元素操作 - 显示常见网页元素创建和修改任务的配方。
- 演示操作 - 显示如何创建和操作演示的配方。
- 幻灯片操作 - 介绍如何在演示文稿中创建、移动和删除幻灯片的配方。
- 表格操作 - 演示如何在幻灯片中创建和修改表格的配方。
- 转换操作 - 演示如何更改幻灯片中元素的大小和位置的配方。
通常,您可以通过多种方式使用 Slides API 完成给定的任务。尽可能使用批处理方法 presentations.batchUpdate
将多个更新请求捆绑到单个方法调用中。这样可以减少客户端 HTTP 开销,减少查询次数,最大限度地减少演示中的修订版本数量,并以原子方式应用所有更改。
如需进一步提升性能,请在读取和更新演示文稿、页面和页面元素时使用字段掩码。
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-08-29。
[null,null,["最后更新时间 (UTC):2025-08-29。"],[],[],null,["# Samples\n\nThis section presents a set of sample applications and \"recipe\" examples that\ndemonstrate how to translate an intended Google Slides action into an\nGoogle Slides API request.\n\nCodelabs\n--------\n\nThe [Slides\ncodelab](https://codelabs.developers.google.com/codelabs/slides-api)\nteaches you how to use Google Slides API as a custom presentation tool for an\nanalysis of the most common software licenses.\n\nYou'll learn how to query all open source code on GitHub using [BigQuery](https://cloud.google.com/bigquery) and create a\nslide deck using Slides API to present your results.\n\nSample applications\n-------------------\n\nThe [Markdown to\nSlides](https://github.com/googleworkspace/md2googleslides)\ncommand-line tool lets you generate slide decks from markdown files.\n\nYou can use this to explore the Slides API, or fork the repository and\nmodify the code to provide Slides output to your JavaScript\napplication.\n\nRecipes\n-------\n\nThe examples listed in this section demonstrate how to express common actions in\nSlides as Slides API requests.\n\nThese examples are presented as HTTP requests to be language neutral. To learn\nhow to implement Slides API request protocols in a specific language\nusing Google API client libraries, see the following guides:\n\n- [Create a slide](/workspace/slides/api/guides/create-slide)\n- [Add shapes and text](/workspace/slides/api/guides/add-shape)\n- [Merge data into a presentation](/workspace/slides/api/guides/merge)\n- [Add charts to a slide](/workspace/slides/api/guides/add-chart)\n- [Edit and style text](/workspace/slides/api/guides/styling)\n\nRecipes in this section are divided into the following categories:\n\n- [Basic reading](/workspace/slides/api/samples/reading)---Recipes that show common ways of reading information from a presentation.\n- [Basic writing](/workspace/slides/api/samples/writing)---Recipes that show common ways of writing to a presentation.\n- [Element operations](/workspace/slides/api/samples/elements)---Recipes that show common page element creation and editing tasks.\n- [Presentation operations](/workspace/slides/api/samples/presentation)---Recipes that show how to create and manipulate a presentation.\n- [Slide operations](/workspace/slides/api/samples/slides)---Recipes that show how to create, move, and delete slides in a presentation.\n- [Table operations](/workspace/slides/api/samples/tables)---Recipes that show how to create and edit tables within a slide.\n- [Transform operations](/workspace/slides/api/samples/transform)---Recipes that show how to alter the size and positioning of elements within a slide.\n\nThere's often more than one way to complete a given task with the\nSlides API. Use the batch method\n[`presentations.batchUpdate`](/workspace/slides/api/reference/rest/v1/presentations/batchUpdate)\nwherever possible to bundle multiple update requests into a single method call.\nThis reduces client HTTP overhead, reduces the number of queries, minimizes the\nnumber of revisions on the presentation, and applies all the changes atomically.\n\nTo further improve performance, use [field\nmasks](/workspace/slides/api/guides/field-masks) when reading and updating presentations,\npages, and page elements."]]