This project is no longer maintained by the owner. The repository will also be deleted soon. See pyteform
A simple python script to extract typeform data from the typeform api.
The following python packages are required to successfully execute the script:
- pandas
- requests
- textblob
- textract
from typeformx import TypeformX
api_key = "MY_API_KEY"
# two arguments may be passed to the constructor
# 1. api key issued by typeform
# 2. optional argument boolean 'complete'
# if true append 'complete=true' at the end of the url to fetch only completed forms the opposite is true.
typeform = TypeformX(api_key, True)
typeform.all_forms() # fetch all typeforms you own
typeform.form_answers('TYPEFORM_ID') # fetch all answers from a typeform
typeform.form_fields('TYPEFORM_ID') # fetch all fields from a typeform
typeform.form_emails('TYPEFORM_ID') #fetch all emails from a typeform
typeform.file_upload_urls('TYPEFORM_ID') #fetch all file upload urls from a typeform
from typeformx import TypeformX, write_to_csv
api_key = "MY_API_KEY"
typeform = TypeformX(api_key, True)
# all forms
all_forms = typeform.all_forms()
for i in range(len(all_forms)):
extracted_info = typeform.file_upload_text(form['id'][i])
filename = form['name'][i].replace(' ', '').replace('/', '').replace('\'', '') # this can be done using a 'clean_filename' function
for extracted in extracted_info:
write_to_csv(extracted, filename+'.csv')
The tests use the nosetest
and mock
packages.
Open typeform_test.py
and add your typeform API KEY then
To run the test script:
nosetests --verbosity=2
- Constructor that takes in two arguments:
- API_KEY (Compulsory type:
string
) - Complete (Optional type:
boolean
)
- API_KEY (Compulsory type:
- Method that writes data to a
.csv
file.- Takes two arguments :
- A list/array of data to write
String
argument denoting the filename
- Takes two arguments :
- Method that retrieves all the typeforms owned by a user.
- Takes one
String
argument :TYPEFORM_ID
- returns a pandas data frame with columns typeform
id
and typeformname
- Takes one
- Method that retrieves all answers from a particular typeform.
- Takes one
String
argument :TYPEFORM_ID
- returns a multidimensional(2D) array/list of
strings
- Takes one
- Method that retrieves all question fields from a particular typeform.
- Takes one
String
argument :TYPEFORM_ID
- returns an array/list of fields.
- Takes one
- Method that retrieves all emails from a particular typeform.
- Takes one
String
argument :TYPEFORM_ID
- returns an array/list of fields
- Takes one
- Method that retrieves all emails, file upload urls and file upload text from a particular typeform.
- Takes one
String
argument :TYPEFORM_ID
- returns a multidimensional(2D) array/list of
strings
- Takes one