Aby zapewnić twórcom formularzy większą kontrolę nad tym, kto może na nie odpowiadać, wprowadzamy szczegółowe ustawienia dla osób, które je wypełniają. Formularze utworzone za pomocą interfejsu API po 31 stycznia 2026 r. będą domyślnie nieopublikowane. Więcej informacji znajdziesz w artykule
Zmiany w interfejsie API Formularzy Google.
Pobieranie formularzy i odpowiedzi
Zadbaj o dobrą organizację dzięki kolekcji
Zapisuj i kategoryzuj treści zgodnie ze swoimi preferencjami.
Interfejs Google Forms API umożliwia pobieranie treści, ustawień i metadanych formularza oraz odpowiedzi użytkowników. Na tej stronie znajdziesz instrukcje wykonywania tych zadań.
Zanim zaczniesz
Zanim przejdziesz do zadań na tej stronie, wykonaj te czynności:
- W instrukcjach dotyczących programu Early Adopter znajdziesz instrukcje autoryzacji/uwierzytelniania i konfiguracji danych logowania.
Pobieranie zawartości i metadanych formularza
Aby pobrać zawartość, ustawienia i metadane formularza, wywołaj metodę forms.get()
z identyfikatorem formularza.
Aby pobrać wszystkie odpowiedzi z formularza, wywołaj metodę forms.responses.list()
z identyfikatorem formularza.
Aby pobrać konkretną odpowiedź z formularza, wywołaj metodę forms.responses.get()
z identyfikatorem formularza i identyfikatorem odpowiedzi.
O ile nie stwierdzono inaczej, treść tej strony jest objęta licencją Creative Commons – uznanie autorstwa 4.0, a fragmenty kodu są dostępne na licencji Apache 2.0. Szczegółowe informacje na ten temat zawierają zasady dotyczące witryny Google Developers. Java jest zastrzeżonym znakiem towarowym firmy Oracle i jej podmiotów stowarzyszonych.
Ostatnia aktualizacja: 2025-04-09 UTC.
[null,null,["Ostatnia aktualizacja: 2025-04-09 UTC."],[],["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```"]]