برای اینکه به سازندگان فرم کنترل بیشتری بر روی افرادی که میتوانند پاسخ دهند، کنترلهای جزئی را برای پاسخدهندگان معرفی میکنیم. فرمهایی که پس از 31 مارس 2026 با API ایجاد میشوند، بهطور پیشفرض وضعیت منتشرنشدهای خواهند داشت. برای کسب اطلاعات بیشتر، تغییرات API در Google Forms را ببینید.
با مجموعهها، منظم بمانید
ذخیره و طبقهبندی محتوا براساس اولویتهای شما.
Google Forms API به شما امکان میدهد محتوای فرم، تنظیمات و ابردادهها و پاسخهای فرم کاربر نهایی را بازیابی کنید. در این صفحه نحوه انجام این وظایف توضیح داده شده است.
قبل از شروع
قبل از ادامه کار در این صفحه، وظایف زیر را انجام دهید:
مجوز/تأیید هویت و تنظیمات اعتبارنامه را در دستورالعمل های Early Adopter Program کامل کنید.
محتویات فرم و ابرداده را بازیابی کنید
برای بازیابی محتوا، تنظیمات و ابرداده یک فرم، متد forms.get() را با شناسه فرم فراخوانی کنید.
fromapiclientimportdiscoveryfromhttplib2importHttpfromoauth2clientimportclient,file,toolsSCOPES="https://www.googleapis.com/auth/forms.body.readonly"DISCOVERY_DOC="https://forms.googleapis.com/$discovery/rest?version=v1"store=file.Storage("token.json")creds=Noneifnotcredsorcreds.invalid:flow=client.flow_from_clientsecrets("client_secrets.json",SCOPES)creds=tools.run_flow(flow,store)service=discovery.build("forms","v1",http=creds.authorize(Http()),discoveryServiceUrl=DISCOVERY_DOC,static_discovery=False,)# Prints the title of the sample form:form_id="<YOUR_FORM_ID>"result=service.forms().get(formId=form_id).execute()print(result)
importpathfrom'node:path';import{authenticate}from'@google-cloud/local-auth';import{forms}from'@googleapis/forms';// TODO: Replace with a valid form ID.constformID='<YOUR_FORM_ID>';/** * Retrieves the content of a form. */asyncfunctiongetForm(){// Authenticate with Google and get an authorized client.constauth=awaitauthenticate({keyfilePath:path.join(__dirname,'credentials.json'),scopes:'https://www.googleapis.com/auth/forms.body.readonly',});// Create a new Forms API client.constformsClient=forms({version:'v1',auth,});// Get the form content.constresult=awaitformsClient.forms.get({formId:formID});console.log(result.data);returnresult.data;}
همه پاسخ های فرم را بازیابی کنید
برای بازیابی همه پاسخ ها از یک فرم، متد forms.responses.list() را با شناسه فرم فراخوانی کنید.
fromapiclientimportdiscoveryfromhttplib2importHttpfromoauth2clientimportclient,file,toolsSCOPES="https://www.googleapis.com/auth/forms.responses.readonly"DISCOVERY_DOC="https://forms.googleapis.com/$discovery/rest?version=v1"store=file.Storage("token.json")creds=Noneifnotcredsorcreds.invalid:flow=client.flow_from_clientsecrets("client_secrets.json",SCOPES)creds=tools.run_flow(flow,store)service=discovery.build("forms","v1",http=creds.authorize(Http()),discoveryServiceUrl=DISCOVERY_DOC,static_discovery=False,)# Prints the responses of your specified form:form_id="<YOUR_FORM_ID>"result=service.forms().responses().list(formId=form_id).execute()print(result)
importpathfrom'node:path';import{authenticate}from'@google-cloud/local-auth';import{forms}from'@googleapis/forms';// TODO: Replace with a valid form ID.constformID='<YOUR_FORM_ID>';/** * Retrieves all responses from a form. */asyncfunctiongetAllResponses(){// Authenticate with Google and get an authorized client.constauth=awaitauthenticate({keyfilePath:path.join(__dirname,'credentials.json'),scopes:'https://www.googleapis.com/auth/forms.responses.readonly',});// Create a new Forms API client.constformsClient=forms({version:'v1',auth,});// Get the list of responses for the form.constresult=awaitformsClient.forms.responses.list({formId:formID,});console.log(result.data);returnresult.data;}
یک پاسخ فرم را بازیابی کنید
برای بازیابی یک پاسخ خاص از یک فرم، متد forms.responses.get() را با شناسه فرم و شناسه پاسخ فراخوانی کنید.
fromapiclientimportdiscoveryfromhttplib2importHttpfromoauth2clientimportclient,file,toolsSCOPES="https://www.googleapis.com/auth/forms.responses.readonly"DISCOVERY_DOC="https://forms.googleapis.com/$discovery/rest?version=v1"store=file.Storage("token.json")creds=Noneifnotcredsorcreds.invalid:flow=client.flow_from_clientsecrets("client_secrets.json",SCOPES)creds=tools.run_flow(flow,store)service=discovery.build("forms","v1",http=creds.authorize(Http()),discoveryServiceUrl=DISCOVERY_DOC,static_discovery=False,)# Prints the specified response from your form:form_id="<YOUR_FORM_ID>"response_id="<YOUR_RESPONSE_ID>"result=(service.forms().responses().get(formId=form_id,responseId=response_id).execute())print(result)
importpathfrom'node:path';import{authenticate}from'@google-cloud/local-auth';import{forms}from'@googleapis/forms';// TODO: Replace with a valid form ID.constformID='<YOUR_FORM_ID>';// TODO: Replace with a valid response ID.constresponseID='<YOUR_RESPONSE_ID>';/** * Retrieves a single response from a form. */asyncfunctiongetSingleResponse(){// Authenticate with Google and get an authorized client.constauth=awaitauthenticate({keyfilePath:path.join(__dirname,'credentials.json'),scopes:'https://www.googleapis.com/auth/forms.responses.readonly',});// Create a new Forms API client.constformsClient=forms({version:'v1',auth,});// Get the specified response from the form.constresult=awaitformsClient.forms.responses.get({formId:formID,responseId:responseID,});console.log(result.data);returnresult.data;}
تاریخ آخرین بهروزرسانی 2025-09-16 بهوقت ساعت هماهنگ جهانی.
[[["درک آسان","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-09-16 بهوقت ساعت هماهنگ جهانی."],[],["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,[]]