Survey Responses

The methods in the Responses module give you the ability pull in survey responses from a specified survey, and to get the specific questions within a given survey.

Get Responses from Survey

Responses.get_responses(survey_id=None)

This function accepts the file format, and the survey id, and returns the responses associated with that survey.

Parameters

survey_id – the id associated with a given survey.

Returns

a Pandas DataFrame with the responses

Example Implementation

In this example say that we want to collect the responses from a survey that we previously conducted. We only need the survey ID, in this case ‘SV_AFakeSurveyID’, and pass it as an argument to the survey_id parameter in the get_responses() method.

#Setup your Credentials, if not already done.
#You only have to do this once.

#Import the module
from QualtricsAPI.Survey import Responses

#Create an instance
r = Responses()

#Call the method
df = r.get_responses(survey_id='SV_AFakeSurveyID')

This will return a pandas DataFrame containing the responses from the survey with the ID, ‘SV_AFakeSurveyID’.

           contact_id   first_name last_name                       email phone unsubscribed  language external_ref
0  CID_FakeContactID1         John      Snow     'therealking@email.com'  None        False      'en'         None
1  CID_FakeContactID2         Bran     Stark          'b.stark@fake.net'  None        False      None         None

Get Questions from Survey

Responses.get_questions(survey_id=None)

This method returns a DataFrame containing the Survey questions and the QuestionIDs.

Parameters

survey_id

Returns

a DataFrame with the Surveys questions

Example Implementation

The real benefit of the get_questions() method comes after having called the get_responses() method. Qualtrics uses an ID system to map the actual questions asked in a survey to a set of IDs (typically dictated by chronological order). This becomes kind of a hassle whenever you are trying to locate a specific question. Here we use the get_questions() method to get the questions associated the survey_id, ‘SV_AFakeSurveyID’.

#Setup your Credentials, if not already done.
#You only have to do this once.

#Import the module
from QualtricsAPI.Survey import Responses

#Create an instance
r = Responses()

#Call the method
df = r.get_questions(survey_id='SV_AFakeSurveyID')

This will return a pandas DataFrame containing the questions associated with the given survey.

           contact_id   first_name last_name                       email phone unsubscribed  language external_ref
0  CID_FakeContactID1         John      Snow     'therealking@email.com'  None        False      'en'         None
1  CID_FakeContactID2         Bran     Stark          'b.stark@fake.net'  None        False      None         None