لمنح صنّاع النماذج مزيدًا من التحكّم في تحديد المستخدمين الذين يمكنهم الردّ، نقدّم عناصر تحكّم دقيقة للمجيبين. ستظهر النماذج التي تم إنشاؤها باستخدام واجهة برمجة التطبيقات بعد 31 كانون الثاني (يناير) 2026 في حالة "غير منشور" تلقائيًا. لمزيد من المعلومات، يُرجى الاطّلاع على
تغييرات واجهة برمجة التطبيقات في "نماذج Google".
استرداد النماذج والردود
تنظيم صفحاتك في مجموعات
يمكنك حفظ المحتوى وتصنيفه حسب إعداداتك المفضّلة.
تتيح لك Google Forms API استرداد محتوى النموذج وإعداداته وبياناته الوصفية،
وردود المستخدم النهائي على النموذج. توضّح هذه الصفحة كيفية تنفيذ هذه
المهام.
قبل البدء
نفِّذ المهام التالية قبل المتابعة مع المهام الواردة في هذه الصفحة:
- أكمِل عملية التفويض/المصادقة وإعداد بيانات الاعتماد في تعليمات
برنامج "المستخدِمون الأوائل".
استرداد محتوى النموذج والبيانات الوصفية
لاسترداد محتوى نموذج وإعداداته وبياناته الوصفية، يمكنك استدعاء الأسلوب
forms.get()
مع تحديد
معرّف النموذج.
لاسترداد جميع الردود من نموذج، يمكنك استدعاء الأسلوب
forms.responses.list()
مع رقم تعريف النموذج.
لاسترداد ردّ معيّن من نموذج، يمكنك استدعاء الأسلوب
forms.responses.get()
مع رقم تعريف النموذج ورقم تعريف الردّ.
إنّ محتوى هذه الصفحة مرخّص بموجب ترخيص Creative Commons Attribution 4.0 ما لم يُنصّ على خلاف ذلك، ونماذج الرموز مرخّصة بموجب ترخيص Apache 2.0. للاطّلاع على التفاصيل، يُرجى مراجعة سياسات موقع Google Developers. إنّ Java هي علامة تجارية مسجَّلة لشركة Oracle و/أو شركائها التابعين.
تاريخ التعديل الأخير: 2025-04-09 (حسب التوقيت العالمي المتفَّق عليه)
[null,null,["تاريخ التعديل الأخير: 2025-04-09 (حسب التوقيت العالمي المتفَّق عليه)"],[],["The Google Forms API allows retrieving form data and responses. To begin, set up authorization/authentication. To get form content, settings, and metadata, use `forms.get()` with the form ID. To retrieve all responses, use `forms.responses.list()` with the form ID. For a single response, use `forms.responses.get()` with both the form ID and specific response ID. Python and Node.js code examples are provided for each action.\n"],null,["# Retrieve forms and responses\n\nThe Google Forms API lets you retrieve form content, settings and metadata,\nand the end-user form responses. This page describes how to perform these\ntasks.\n\nBefore you begin\n----------------\n\nPerform the following tasks before proceeding with the tasks on this page:\n\n- Complete authorization/authentication and credentials setup in the Early Adopter Program instructions.\n\nRetrieve form contents and metadata\n-----------------------------------\n\nTo retrieve the content, settings, and metadata of a form, call the\n[`forms.get()`](/workspace/forms/api/reference/rest/v1/forms/get) method with\nthe form ID. \n\n### Python\n\nforms/snippets/retrieve_contents.py \n[View on GitHub](https://github.com/googleworkspace/python-samples/blob/main/forms/snippets/retrieve_contents.py) \n\n```python\nfrom apiclient import discovery\nfrom httplib2 import Http\nfrom oauth2client import client, file, tools\n\nSCOPES = \"https://www.googleapis.com/auth/forms.body.readonly\"\nDISCOVERY_DOC = \"https://forms.googleapis.com/$discovery/rest?version=v1\"\n\nstore = file.Storage(\"token.json\")\ncreds = None\nif not creds or creds.invalid:\n flow = client.flow_from_clientsecrets(\"client_secrets.json\", SCOPES)\n creds = tools.run_flow(flow, store)\nservice = discovery.build(\n \"forms\",\n \"v1\",\n http=creds.authorize(Http()),\n discoveryServiceUrl=DISCOVERY_DOC,\n static_discovery=False,\n)\n\n# Prints the title of the sample form:\nform_id = \"\u003cYOUR_FORM_ID\u003e\"\nresult = service.forms().get(formId=form_id).execute()\nprint(result)\n```\n\n### Node.js\n\nforms/snippets/get_form.js \n[View on GitHub](https://github.com/googleworkspace/node-samples/blob/main/forms/snippets/get_form.js) \n\n```javascript\n'use strict';\n\nconst path = require('path');\nconst google = require('@googleapis/forms');\nconst {authenticate} = require('@google-cloud/local-auth');\n\nconst formID = '\u003cYOUR_FORM_ID\u003e';\n\nasync function runSample(query) {\n const auth = await authenticate({\n keyfilePath: path.join(__dirname, 'credentials.json'),\n scopes: 'https://www.googleapis.com/auth/forms.body.readonly',\n });\n const forms = google.forms({\n version: 'v1',\n auth: auth,\n });\n const res = await forms.forms.get({formId: formID});\n console.log(res.data);\n return res.data;\n}\n\nif (module === require.main) {\n runSample().catch(console.error);\n}\nmodule.exports = runSample;\n```\n\nRetrieve all form responses\n---------------------------\n\nTo retrieve all of the responses from a form, call the\n[`forms.responses.list()`](/workspace/forms/api/reference/rest/v1/forms.responses/list)\nmethod with the form ID. \n\n### Python\n\nforms/snippets/retrieve_all_responses.py \n[View on GitHub](https://github.com/googleworkspace/python-samples/blob/main/forms/snippets/retrieve_all_responses.py) \n\n```python\nfrom apiclient import discovery\nfrom httplib2 import Http\nfrom oauth2client import client, file, tools\n\nSCOPES = \"https://www.googleapis.com/auth/forms.responses.readonly\"\nDISCOVERY_DOC = \"https://forms.googleapis.com/$discovery/rest?version=v1\"\n\nstore = file.Storage(\"token.json\")\ncreds = None\nif not creds or creds.invalid:\n flow = client.flow_from_clientsecrets(\"client_secrets.json\", SCOPES)\n creds = tools.run_flow(flow, store)\nservice = discovery.build(\n \"forms\",\n \"v1\",\n http=creds.authorize(Http()),\n discoveryServiceUrl=DISCOVERY_DOC,\n static_discovery=False,\n)\n\n# Prints the responses of your specified form:\nform_id = \"\u003cYOUR_FORM_ID\u003e\"\nresult = service.forms().responses().list(formId=form_id).execute()\nprint(result)\n```\n\n### Node.js\n\nforms/snippets/get_all_responses.js \n[View on GitHub](https://github.com/googleworkspace/node-samples/blob/main/forms/snippets/get_all_responses.js) \n\n```javascript\n'use strict';\n\nconst path = require('path');\nconst google = require('@googleapis/forms');\nconst {authenticate} = require('@google-cloud/local-auth');\n\nconst formID = '\u003cYOUR_FORM_ID\u003e';\n\nasync function runSample(query) {\n const auth = await authenticate({\n keyfilePath: path.join(__dirname, 'credentials.json'),\n scopes: 'https://www.googleapis.com/auth/forms.responses.readonly',\n });\n const forms = google.forms({\n version: 'v1',\n auth: auth,\n });\n const res = await forms.forms.responses.list({\n formId: formID,\n });\n console.log(res.data);\n return res.data;\n}\n\nif (module === require.main) {\n runSample().catch(console.error);\n}\nmodule.exports = runSample;\n```\n\nRetrieve a single form response\n-------------------------------\n\nTo retrieve a specific response from a form, call the\n[`forms.responses.get()`](/workspace/forms/api/reference/rest/v1/forms.responses/get)\nmethod with the form ID and the response ID. \n\n### Python\n\nforms/snippets/retrieve_single_response.py \n[View on GitHub](https://github.com/googleworkspace/python-samples/blob/main/forms/snippets/retrieve_single_response.py) \n\n```python\nfrom apiclient import discovery\nfrom httplib2 import Http\nfrom oauth2client import client, file, tools\n\nSCOPES = \"https://www.googleapis.com/auth/forms.responses.readonly\"\nDISCOVERY_DOC = \"https://forms.googleapis.com/$discovery/rest?version=v1\"\n\nstore = file.Storage(\"token.json\")\ncreds = None\nif not creds or creds.invalid:\n flow = client.flow_from_clientsecrets(\"client_secrets.json\", SCOPES)\n creds = tools.run_flow(flow, store)\nservice = discovery.build(\n \"forms\",\n \"v1\",\n http=creds.authorize(Http()),\n discoveryServiceUrl=DISCOVERY_DOC,\n static_discovery=False,\n)\n\n# Prints the specified response from your form:\nform_id = \"\u003cYOUR_FORM_ID\u003e\"\nresponse_id = \"\u003cYOUR_RESPONSE_ID\u003e\"\nresult = (\n service.forms()\n .responses()\n .get(formId=form_id, responseId=response_id)\n .execute()\n)\nprint(result)\n```\n\n### Node.js\n\nforms/snippets/get_single_response.js \n[View on GitHub](https://github.com/googleworkspace/node-samples/blob/main/forms/snippets/get_single_response.js) \n\n```javascript\n'use strict';\n\nconst path = require('path');\nconst google = require('@googleapis/forms');\nconst {authenticate} = require('@google-cloud/local-auth');\n\nconst formID = '\u003cYOUR_FORM_ID\u003e';\nconst responseID = '\u003cYOUR_RESPONSE_ID\u003e';\n\nasync function runSample(query) {\n const auth = await authenticate({\n keyfilePath: path.join(__dirname, 'credentials.json'),\n scopes: 'https://www.googleapis.com/auth/forms.responses.readonly',\n });\n const forms = google.forms({\n version: 'v1',\n auth: auth,\n });\n const res = await forms.forms.responses.get({\n formId: formID,\n responseId: responseID,\n });\n console.log(res.data);\n return res.data;\n}\n\nif (module === require.main) {\n runSample().catch(console.error);\n}\nmodule.exports = runSample;\n```"]]