This Python script fetches responses from a Google Form using the Google Forms API and stores them in data.json
.
- Install Python 3 if not already installed.
- Install the required dependencies:
pip install -r requiement.txt
- Set up Google Cloud credentials:
- Create a project in the Google Cloud Console.
- Enable the Google Forms API.
- Download
credentials.json
from the Google Cloud Console and place it in the project directory.
- Run the script:
python main.py
- The script will fetch all responses from the specified Google Form and append them to
data.json
.
- Authenticates using OAuth2 and stores the token in
token.json
. - Fetches metadata of the specified form.
- Retrieves all responses to the form.
- Loops through all responses and appends them to
data.json
.
A data.json
file containing:
{
"responses": [
{
"responseId": "abc123",
"answers": { "question1": "answer1", "question2": "answer2" }
},
...
]
}
- Ensure
credentials.json
is correctly configured. - Update the
form_id
in the script with your Google Form ID. - Modify the response processing logic as needed.
- Extend this script to support other Google APIs, such as Google Sheets, Google Drive, or Google Calendar.
- Use this repository as a trial environment to experiment with and test various Google APIs before integrating them into larger projects.
Happy Coding! 🚀