为了让表单创建者能够更好地控制哪些人可以回复,我们将为回复者引入精细的控制功能。2026 年 1 月 31 日之后使用该 API 创建的表单将默认处于未发布状态。如需了解详情,请参阅
Google 表单的 API 变更。
将 REST API 与表单服务进行比较
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
Google Forms API 和 Apps 脚本上的 Google 表单服务可以执行的操作有一些重叠。本指南介绍了这两种方法的异同,可帮助您确定哪种方法最适合您的项目。
支持的表单功能
REST API 和 Apps Script 上的 Google 表单服务都支持对方不支持的 Google 表单功能。由于受支持功能的确切列表会随时间而变化,因此请参阅文档的其余部分,了解特定功能目前是否受支持。
不过,某些功能可能永远不会受支持,如下所述。
REST API 不打算支持以下内容:
- 提交表单回复
- 在 Pub/Sub 通知正文中添加详细的表单或回复数据
Apps 脚本上的 Google 表单服务不打算支持以下功能:
- 使用 Cloud Pub/Sub 订阅表单事件
- 为非单选题类型设置正确答案
请求新的 REST API 功能
REST API 比 Apps Script 上的 Google 表单服务更新,并且会定期添加新功能。如果您希望我们优先考虑某项功能,请提交功能请求。
基于事件的行为
{apps_script_name_short} 触发器和 REST API 中的 forms.watches
资源都可以在表单发生变化时执行操作。
在以下情况下,请优先使用 REST API 的 forms.watches
:
- 最高可靠性
- 与 Cloud Pub/Sub 的互操作性
- 表单被修改时的通知
以下情况应优先使用 Apps 脚本触发器:
配额
Apps Script 和 Google 表单 API 具有不同的服务限制。
语言和环境
如果您更喜欢使用 JavaScript 进行开发,Apps Script 可以自动设置 Cloud 控制台项目和 OAuth 意见征求流程,从而为您节省时间。Apps 脚本还提供基于浏览器的代码编辑器,并在 Google 服务器上运行您的代码。
另一方面,除了 JavaScript 之外,REST API 还提供多种语言的客户端库,让您可以使用自己选择的语言进行开发,而不受运行时或同时执行限制。
通过 Apps Script 使用 REST API
如果您更喜欢使用 Apps Script 开发环境,但想使用 Google 表单 REST API 功能,可以使用 UrlFetchApp
来实现。如需了解详情,请参阅设置 Apps 脚本项目。
Google 表单 REST API 尚未作为 Apps 脚本高级服务提供。如果您希望我们支持该功能,请提交功能请求。
后续步骤
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-04-09。
[null,null,["最后更新时间 (UTC):2025-04-09。"],[],["The Google Forms API and Apps Script's Forms Service offer overlapping functionalities, but with key distinctions. The REST API doesn't support submitting responses or detailed data in pub/sub notifications, while Apps Script lacks Cloud Pub/Sub subscription and setting non-multiple-choice answers. The REST API's `forms.watches` is favored for reliability and form edits, while Apps Script triggers offer data-rich notifications and time-based triggers. They have separate service limits, languages and development environments. Developers can use the REST API from within Apps Script using `UrlFetchApp`.\n"],null,["# Compare REST API with Forms Service\n\nThere is some overlap in what you can do with the Google Forms API and the\n[Forms Service on Apps Script](/apps-script/reference/forms). This guide covers\nsimilarities and differences to help you decide which is best for your project.\n\nSupported Forms features\n------------------------\n\nBoth the REST API and the Forms Service on Apps Script support Forms features\nthat the other does not. Because the exact list of supported features changes\nover time, please explore the rest of the documentation to find out whether a\nparticular feature is currently supported.\n\nHowever, certain features are unlikely to ever be supported, as described below.\n\nThe REST API does not plan to support:\n\n- Submitting form responses\n- Including detailed form or response data in the body of pub/sub notifications\n\nThe Forms Service on Apps Script does not plan to support:\n\n- Subscribing to form events with Cloud Pub/Sub\n- Setting correct answers for question types that are not multiple choice\n\n### Request a new REST API feature\n\nThe REST API is newer than the Forms Service on Apps Script and new features\nare added regularly. Please\n[file a feature request](https://issuetracker.google.com/issues?q=componentid:978479%20status:open)\nif you would like to see a certain feature prioritized.\n\nEvent-based behavior\n--------------------\n\nBoth [{apps_script_name_short} triggers](/apps-script/guides/triggers) and the\n[`forms.watches` resource in the REST API](/workspace/forms/api/guides/push-notifications)\nprovide a way to take action when a form changes.\n\nPrefer the REST API's `forms.watches` for:\n\n- Maximum [reliability](/workspace/forms/api/guides/push-notifications#reliability)\n- Interoperability with Cloud Pub/Sub\n- Notifications when forms are edited\n\nPrefer Apps Script triggers for:\n\n- Form or response data included with each notification\n- Time-based triggers\n\nQuotas\n------\n\nApps Script and the Forms API have different service limits.\n\n- Learn more about [Apps Script quotas](/apps-script/guides/services/quotas)\n- Learn more about [Forms API usage limits](/workspace/forms/api/limits)\n\nLanguages and environments\n--------------------------\n\nIf you prefer to develop in JavaScript, Apps Script can save you time by\nautomating the setup of a Cloud Console project and an OAuth consent flow.\nApps Script also provides a browser-based code editor and runs your code on\nGoogle servers.\n\nOn the other hand, the REST API provides client libraries in many languages\nbesides JavaScript, freeing you to develop in the language of your choice and\nnot be subject to\n[limits on runtime or simultaneous executions](/apps-script/guides/services/quotas#current_limitations).\n\n### Use the REST API from Apps Script\n\nIf you prefer the Apps Script development environment but want to use Forms\nREST API features, you can do so using `UrlFetchApp`. For more information, see\n[Set up an Apps Script project](/workspace/forms/api/guides/apps-script-setup).\n\nThe Forms REST API is not yet available as an\n[Apps Script advanced service](/apps-script/guides/services/advanced). Please\n[file a feature request](https://issuetracker.google.com/issues?q=componentid:978479%20status:open)\nif you would like it to be supported.\n\nNext steps\n==========\n\n- [Get started with the REST API](/workspace/forms/api/guides)\n- [Explore an overview of Apps Script](https://developers.google.com/apps-script/overview)\n- [Try out the Apps Script web app](/workspace/forms/api/guides/apps-script-example)"]]