SIGN UP FREE

Survey Design

Tip and tricks for writing great questions for online questionnaires

Home View All Resources Articles

Survey Design - Writing Great Questions for Online Surveys

API stands for "application programming interface." This Wikipedia article covers APIs in more detail, but it can be helpful to think of the API as a way for different apps to talk to one another. For many users, the main interaction with the API will be through API access key, a way for other apps to access your account without you giving out your password.

The QuestionPro API is organized around REST. We use built-in HTTP features, like HTTP authentication and HTTP verbs, to allow you to interact securely with our API from a client-side web application. JSON will be returned in all responses from the API, including errors.

Note: Our API supports maximum 100 responses per API call.

API Endpoint

http://api.questionpro.com/a/api



API Request Limits

Team Edition Enterprise
Responses per call (surveyResponses) 100 100
Email invites sent per call (sendSurvey) 100 100
Email Uploads per call (createEmailGroup) 100 100
Free API calls 100 500
Cost per call (after free calls) $0.1 $0.1

Authentication

You authenticate to the QuestionPro API by providing your API key in the request. You can get your API key from your account:

  • Login to QuestionPro and navigate to Integration » Developer API

  • Click on 'Get API Key' button and the key will be generated.

In order to make the API calls you'll also need to provide the survey ID for the required survey.

Sample Request

api.setAccessKey("xxxxx"); api.setSurveyID(xxxxx); public void setSurveyID(long val){surveyID=val;} public void setAccessKey(String val){accessKey=val;} public long getSurveyID(){return surveyID;} public String getAccessKey(){return accessKey;}

Get Total Response Count

Method: questionpro.survey.responseCount

This API call will return total survey response count based on the filtering criteria.

Attributes

Name Value Required
id Survey ID
resultMode
Assign following values to resultMode to get different responses
  • 0 - All survey responses (Default)
  • 1 - Started but Not Completed survey responses
  • 2 - Completed survey responses
  • 3 - Terminated via Branching survey responses
startDate* Start Date for response time range - Date Format is MM/DD/YYYY
endDate* End Date for response time range - Date Format is MM/DD/YYYY

*Either both Start Date and End Date have to be entered else neither

URL

http://api.questionpro.com/a/api/questionpro.survey.responseCount

Sample Request

public String getSurveyResponseCountUrl() { return "http://api.questionpro.com/a/api/questionpro.survey.responseCount?accessKey=" + getAccessKey(); } public long getResponseCount() throws Exception { String path = getSurveyResponseCountUrl(); DefaultHttpClient httpclient = new DefaultHttpClient(); HttpPost httpost = new HttpPost(path); String data = "{"id":"" + getSurveyID() + "","resultMode":"0", "startDate":"01/14/2013"," + ""endDate":"01/15/2013"}"; StringEntity se = new StringEntity(data); httpost.setEntity(se); httpost.setHeader("Accept", "application/json"); httpost.setHeader("Content-type", "application/json"); ResponseHandler responseHandler = new BasicResponseHandler(); Object resp = httpclient.execute(httpost, responseHandler); String json = resp.toString(); JSONObject obj = new JSONObject(json); obj = obj.getJSONObject("response"); System.out.println(" Survey : " + obj.opt("name") + " Status : " + obj.opt("status") + " Overall Viewed : " + obj.optLong("overallViewedCount") + " Overall Started : " + obj.optLong("overallStartedCount") + " Overall Complete : " + obj.optLong("overallCompleteCount") + " Started Count: " + obj.optLong("startedCount") + " Complete Count : " + obj.optLong("completeCount")); return obj.getLong("overallStartedCount"); }



Sample Response

{ "response" : { "completeCount" : 6, "id" : 3896108, "name" : "Sample Survey", "overallCompleteCount" : 6, "overallStartedCount" : 6, "overallTerminatedCount" : 0, "overallViewedCount" : 7, "partialCount" : 6, "startedCount" : 6, "status" : "Active", "terminatedCount" : 0 }, "status" : { "id" : 200, "message" : "OK", "method" : "questionpro.survey.responseCount", "serverUTC" : 1403250725110, "url" : "/a/api/questionpro.survey.responseCount" } }



Get Survey Responses

Method: questionpro.survey.surveyResponses

This API call is used to retrieve survey responses for a survey based on the filtering criteria.

Attributes

Name Value Required
id Survey ID
resultMode
Assign following values to resultMode to get different responses
  • 0 - All survey responses (Default)
  • 1 - Started but Not Completed survey responses
  • 2 - Completed survey responses
  • 3 - Terminated via Branching survey responses
startDate* Start Date for response time range - Date Format is MM/DD/YYYY
endDate* End Date for response time range - Date Format is MM/DD/YYYY
startingResponseCounter This parameter is used to get responses in a particular range sequentially. If this parameter is not specified the first 100 responses will be returned, If '2' is specified, responses in the range 201-300 will be returned and so on.

*Either both Start Date and End Date have to be entered else neither

URL

http://api.questionpro.com/a/api/questionpro.survey.surveyResponses

Sample Request

public String getSurveyResponseUrl() { return "http://api.questionpro.com/a/api/questionpro.survey.surveyResponse?accessKey=" + getAccessKey(); } public String getResponses(int startingResponseCounter) throws Exception { String path = getSurveyResponsesUrl(); DefaultHttpClient httpclient = new DefaultHttpClient(); HttpPost httpost = new HttpPost(path); String data = "{"id":"" + getSurveyID() + "","resultMode":"0","startDate":"01/01/2013"," + ""endDate":"07/24/2013","startingResponseCounter":""+ startingResponseCounter +""}"; StringEntity se = new StringEntity(data); httpost.setEntity(se); httpost.setHeader("Accept", "application/json"); httpost.setHeader("Content-type", "application/json"); ResponseHandler responseHandler = new BasicResponseHandler(); Object resp = httpclient.execute(httpost, responseHandler); return resp.toString(); }


Sample Response

{ "response" : { "id" : 3896108, "name" : "Sample Survey", "responses" : [ { "country" : "IN", "duplicate" : false, "externalReference" : "test_response", "id" : 23749765, "ipAddress" : "115.248.168.125", "region" : "16", "responseSet" : [ { "questionCode" : "Q1", "questionDescription" : " ", "questionID" : 36860852, "questionText" : "How often do you conduct surveys?", "values" : [ { "answerText" : "Weekly", "id" : "181377002", "value" : { "scale" : "1" } } ] } ], "responseStatus" : "Yes", "timeTaken" : 2, "timestamp" : "20 Jun, 2014 11:50:05 AM MSD" }, { "country" : "IN", "duplicate" : false, "externalReference" : "test_response", "id" : 23749766, "ipAddress" : "115.248.168.125", "region" : "16", "responseSet" : [ { "questionCode" : "Q1", "questionDescription" : " ", "questionID" : 36860852, "questionText" : "How often do you conduct surveys?", "values" : [ { "answerText" : "Quarterly", "id" : "181377004", "value" : { "scale" : "3" } } ] } ], "responseStatus" : "Yes", "timeTaken" : 1, "timestamp" : "20 Jun, 2014 11:50:09 AM MSD" } ], "status" : "Active", "surveyStatistics" : { "completedCount" : 6, "startedCount" : 6, "viewedCount" : 0 } }, "status" : { "id" : 200, "message" : "OK", "method" : "questionpro.survey.surveyResponses", "serverUTC" : 1403258290868, "url" : "/a/api/questionpro.survey.surveyResponses" } }



Get Send Survey Meta Data

Method: questionpro.survey.sendSurveyMetaData

This API call will return information related to email groups and templates for the user. This information can be used along with sendSurvey API call

Attributes

Name Value Required
id Survey ID

URL

http://api.questionpro.com/a/api/questionpro.survey.sendSurveyMetaData

Sample Request

public String getSendSurveyMetaDataUrl() { return "http://api.questionpro.com/a/api/questionpro.survey.sendSurveyMetaData?accessKey=" + getAccessKey(); } public JSONObject getSendSurveyMetaData() throws Exception { String path = getSendSurveyMetaDataUrl(); DefaultHttpClient httpclient = new DefaultHttpClient(); HttpPost httpost = new HttpPost(path); //String data = "{"surveyID":"" + getSurveyID() + ""}"; JSONObject data = new JSONObject(); data.put("surveyID", getSurveyID()); StringEntity se = new StringEntity(data.toString()); httpost.setEntity(se); httpost.setHeader("Accept", "application/json"); httpost.setHeader("Content-type", "application/json"); ResponseHandler responseHandler = new BasicResponseHandler(); Object resp = httpclient.execute(httpost, responseHandler); JSONObject meta = new JSONObject( resp.toString()); JSONObject response = meta.getJSONObject("response"); JSONArray emailGroups = response.getJSONArray("emailGroups"); JSONArray templates = response.getJSONArray("templates"); for (int i=0; i < emailGroups.length();i++) { JSONObject jsonEg = emailGroups.getJSONObject(i); System.out.println("Email Group ID : " + jsonEg.getLong("emailGroupID") + " Name : " + jsonEg.getString("emailGroupName")); } for (int i=0; i < templates.length();i++) { JSONObject jsonSc = templates.getJSONObject(i); System.out.println("Template ID : " + jsonSc.getLong("templateID") + " Subject : " + jsonSc.getString("templateSubject")); } return meta; }



Sample Response

{ "response" : { "emailGroups" : [ { "emailGroupID" : 664235, "emailGroupName" : "Default List- 1" }, { "emailGroupID" : 664234, "emailGroupName" : "QPTest" } ], "templates" : [ { "templateID" : 87278, "templateSubject" : "Template0Survey Invitation template 2" } ] }, "status" : { "id" : 200, "message" : "OK", "method" : "questionpro.survey.sendSurveyMetaData", "serverUTC" : 1378809379946, "url" : "/a/api/questionpro.survey.sendSurveyMetaData" } }



Send Survey

Method: questionpro.survey.sendSurvey

This API is used to send survey invitations to individual respondents as well as email lists.

Attributes

Name Value Required
surveyID Survey ID
mode
  • 1 - Send invites to an existing email list using an existing email template
  • 2 - Send invites to individual email addresses using an existing email template
  • 3 - Send invites to existing email list using a custom email template
  • 4 - Send invites to individual email addresses using a custom email template
emailGroupID ID for the email list to which you want to send invites. Required with mode 1 and mode 3
templateID Email template to be used. Required with mode 1 and mode 2
emails Email addresses of the respondents (JSONArray). Required with mode 2 and mode 4
template Custom email template (JSONArray with attributes 'body' & 'subject'). Required with mode 3 and mode 4

URL

http://api.questionpro.com/a/api/questionpro.survey.sendSurvey

Sample Request

public String getSendSurveyUrl() { return "http://api.questionpro.com/a/api/questionpro.survey.sendSurvey?accessKey=" + getAccessKey(); } public JSONObject getSendSurvey1() throws Exception { String path = getSendSurveyUrl(); DefaultHttpClient httpclient = new DefaultHttpClient(); HttpPost httpost = new HttpPost(path); JSONObject data = new JSONObject(); data.put("surveyID", getSurveyID()); data.put("emailGroupID", 1234); data.put("templateID", 5678); data.put("mode", 1); StringEntity se = new StringEntity(data.toString()); httpost.setEntity(se); httpost.setHeader("Accept", "application/json"); httpost.setHeader("Content-type", "application/json"); ResponseHandler responseHandler = new BasicResponseHandler(); Object resp = httpclient.execute(httpost, responseHandler); return new JSONObject(resp.toString()); } public JSONObject getSendSurvey2() throws Exception { String path = getSendSurveyUrl(); DefaultHttpClient httpclient = new DefaultHttpClient(); HttpPost httpost = new HttpPost(path); JSONObject data = new JSONObject(); JSONArray emails = new JSONArray(); emails.put("[email protected]"); emails.put("[email protected]"); data.put("surveyID", getSurveyID()); data.put("emails", emails); data.put("templateID", 5678); data.put("mode", 2); StringEntity se = new StringEntity(data.toString()); httpost.setEntity(se); httpost.setHeader("Accept", "application/json"); httpost.setHeader("Content-type", "application/json"); ResponseHandler responseHandler = new BasicResponseHandler(); Object resp = httpclient.execute(httpost, responseHandler); return new JSONObject(resp.toString()); } public JSONObject getSendSurvey3() throws Exception { String path = getSendSurveyUrl(); DefaultHttpClient httpclient = new DefaultHttpClient(); HttpPost httpost = new HttpPost(path); JSONObject data = new JSONObject(); JSONObject template = new JSONObject(); template.put("body", "Please take the survey : "); template.put("subject", "This is subject"); data.put("surveyID", getSurveyID()); data.put("emailGroupID", 1234); data.put("template", template); data.put("mode", 3); StringEntity se = new StringEntity(data.toString()); httpost.setEntity(se); httpost.setHeader("Accept", "application/json"); httpost.setHeader("Content-type", "application/json"); ResponseHandler responseHandler = new BasicResponseHandler(); Object resp = httpclient.execute(httpost, responseHandler); return new JSONObject(resp.toString()); } public JSONObject getSendSurvey4() throws Exception { String path = getSendSurveyUrl(); DefaultHttpClient httpclient = new DefaultHttpClient(); HttpPost httpost = new HttpPost(path); JSONObject data = new JSONObject(); JSONArray emails = new JSONArray(); emails.put("[email protected]"); emails.put("[email protected]"); JSONObject template = new JSONObject(); template.put("body", "Please take the survey : "); template.put("subject", "This is subject"); data.put("surveyID", getSurveyID()); data.put("emails", emails); data.put("template", template); data.put("mode", 4); StringEntity se = new StringEntity(data.toString()); httpost.setEntity(se); httpost.setHeader("Accept", "application/json"); httpost.setHeader("Content-type", "application/json"); ResponseHandler responseHandler = new BasicResponseHandler(); Object resp = httpclient.execute(httpost, responseHandler); return new JSONObject(resp.toString()); }



Sample Response

{ "response" : { "result" : "Message successful." }, "status" : { "id" : 200, "message" : "OK", "method" : "questionpro.survey.sendSurvey", "serverUTC" : 1378810004358, "url" : "/a/api/questionpro.survey.sendSurvey" } }



Get Survey Invite History

Method: questionpro.survey.emailBatchStatistics

This API call can be used to get the send survey history for a specific survey.

Attributes

Name Value Required
surveyID Survey ID

URL

http://api.questionpro.com/a/api/questionpro.survey.emailBatchStatistics

Sample Request

public String getEmailBatchStatisticsURL(){ return "http://api.questionpro.com/a/api/questionpro.survey.emailBatchStatistics?accessKey=" + getAccessKey(); } public JSONObject getEmailBatchStatistics() throws Exception { String path = deleteSurveyURL(); DefaultHttpClient httpclient = new DefaultHttpClient(); HttpPost httpost = new HttpPost(path); JSONObject data = new JSONObject(); data.put("surveyID", getSurveyID()); StringEntity se = new StringEntity(data.toString()); httpost.setEntity(se); httpost.setHeader("Accept", "application/json"); httpost.setHeader("Content-type", "application/json"); ResponseHandler responseHandler = new BasicResponseHandler(); Object resp = httpclient.execute(httpost, responseHandler); return new JSONObject(resp.toString()); }



Sample Response

{ "response": { "emailBatches": [ { "emailGroup": "Default List-1", "viewed": 0, "completed": 0, "batchID": 1499762, "participationRate": "0%", "batchType": "Normal", "participationPending": 2, "timestamp": "02/08/2016 16:02:53", "initialSent": 2, "status": "Completed Successfully" }, { "emailGroup": "test", "viewed": 0, "completed": 0, "batchID": 945908, "participationRate": "0%", "batchType": "Normal", "participationPending": 3, "timestamp": "18/04/2013 11:35:38", "initialSent": 3, "status": "Completed Successfully" } ] }, "status": { "method": "questionpro.survey.emailBatchStatistics", "serverUTC": 1470390987145, "id": 200, "message": "OK", "url": "/a/api/questionpro.survey.emailBatchStatistics" } }



Send Reminders

Method: questionpro.survey.sendReminder

This API call is used to send reminders to previously sent email batches

Attributes

Name Value Required
surveyID Survey ID
emailGroupID ID for the email list to which you want to send reminders.
templateID Email template to be used.

URL

http://api.questionpro.com/a/api/questionpro.survey.sendReminder

Sample Request

public String getSendReminderUrl() { return "http://api.questionpro.com/a/api/questionpro.survey.sendReminder?accessKey=" + getAccessKey(); } public JSONObject getSendReminder() throws Exception { String path = getSendReminderUrl(); DefaultHttpClient httpclient = new DefaultHttpClient(); HttpPost httpost = new HttpPost(path); JSONObject data = new JSONObject(); data.put("surveyID", getSurveyID()); data.put("emailGroupID", 1234); data.put("templateID", 5678); StringEntity se = new StringEntity(data.toString()); httpost.setEntity(se); httpost.setHeader("Accept", "application/json"); httpost.setHeader("Content-type", "application/json"); ResponseHandler responseHandler = new BasicResponseHandler(); Object resp = httpclient.execute(httpost, responseHandler); return new JSONObject(resp.toString()); }



Sample Response

{ "response" : { "result" : "Message successful." }, "status" : { "id" : 200, "message" : "OK", "method" : "questionpro.survey.sendSurvey", "serverUTC" : 1378810004358, "url" : "/a/api/questionpro.survey.sendSurvey" } }



Create User

Method: questionpro.survey.createUser

You can create user accounts using this API call. Please note that you will require a global access key to make this call.

Attributes

Name Value Required
emailAddress Login email address for the new user ✔

URL

http://api.questionpro.com/a/api/questionpro.survey.createUser

Sample Request

public String getSurveyResponseCountUrl() { return "http://api.questionpro.com/a/api/questionpro.survey.createUser?accessKey=" + getGlobalAccessKey(); } public long getResponseCount() throws Exception { String path = getSurveyResponseCountUrl(); DefaultHttpClient httpclient = new DefaultHttpClient(); HttpPost httpost = new HttpPost(path); String data = "{\"emailAddress\":\"[email protected]\"}"; StringEntity se = new StringEntity(data); httpost.setEntity(se); httpost.setHeader("Accept", "application/json"); httpost.setHeader("Content-type", "application/json"); ResponseHandler responseHandler = new BasicResponseHandler(); Object resp = httpclient.execute(httpost, responseHandler); return resp; }



Sample Response

{ "response":{ "emailAddress":"[email protected]", "password":"kwnde", "success":1 }, "status":{ "method":"questionpro.survey.createUser", "serverUTC":1412076126669, "id":200, "message":"OK", "url":"/a/api/questionpro.survey.createUser" } }



Create Email List

Method: questionpro.survey.createEmailGroup

This API call can be used to create email lists for a specific survey.

Attributes

Name Value Required
surveyID Survey ID ✔
Emails
Email addresses with custom variables (JSON Array)
✔

URL

http://api.questionpro.com/a/api/questionpro.survey.createEmailGroup

Sample Request

public String getCreateEmailGroupURL(){ return "http://api.questionpro.com/a/api/questionpro.survey.createEmailGroup?accessKey=" + getAccessKey(); } public JSONObject createEmailGroup() throws Exception { String path = getCreateEmailGroupURL(); DefaultHttpClient httpclient = new DefaultHttpClient(); HttpPost httpost = new HttpPost(path); JSONObject data = new JSONObject(); JSONArray emails = new JSONArray(); emails.put("[email protected],custom1,custom2"); emails.put("[email protected],custom1,custom2"); data.put("surveyID", getSurveyID()); data.put("emails", emails); StringEntity se = new StringEntity(data.toString()); httpost.setEntity(se); httpost.setHeader("Accept", "application/json"); httpost.setHeader("Content-type", "application/json"); ResponseHandler responseHandler = new BasicResponseHandler(); Object resp = httpclient.execute(httpost, responseHandler); return new JSONObject(resp.toString()); }



Sample Response

{ "response":{ "result":{ "emailGroupID":847771 } }, "status":{ "method":"questionpro.survey.createEmailGroup", "serverUTC":1439556596337, "id":200, "message":"OK", "url":"/a/api/questionpro.survey.createEmailGroup" } }



List All User Accounts

Method: questionpro.survey.getAllAccounts

You can get all user accounts using this API call. Please note that you will require a global access key to make this call.

Attributes

Name Value Required
userID Logged in user id

*User ID is optional as it is extracted from access key and this call requires no data to be passed in request

URL

http://api.questionpro.com/a/api/questionpro.survey.getAllAccounts

Sample Request

public String getAllAccountsUrl() { return "http://api.questionpro.com/a/api/questionpro.survey.getAllAccounts?accessKey=" + getGlobalAccessKey(); } public JSONObject getAllAccounts() throws Exception { String path = getAllAccountsUrl(); DefaultHttpClient httpclient = new DefaultHttpClient(); HttpPost httpost = new HttpPost(path); httpost.setHeader("Accept", "application/json"); httpost.setHeader("Content-type", "application/json"); ResponseHandler responseHandler = new BasicResponseHandler(); Object resp = httpclient.execute(httpost, responseHandler); return resp; }



Sample Response

{ "response": { "accounts": [ { "firstName": "xyz", "lastName": "pqr", "lastLogin": "0 days(s) ago", "emailAddress": "[email protected]", "phone": "(IN)9876543210", "accountType": "Uber Admin User", "creationDate": "Nov 17, 2010", "userID": 1234 }, { "lastLogin": "1288 days(s) ago", "emailAddress": "[email protected]", "phone": "", "accountType": "Recurring Billing Deactivated", "creationDate": "Feb 21, 2011", "userID": 2345 }, { "lastLogin": "N/A", "emailAddress": "[email protected]", "phone": "", "accountType": "Dashboard", "creationDate": "May 12, 2015", "userID": 3456 }, ] }, "status": { "method": "questionpro.survey.getAllAccounts", "apiKey": "xxx", "serverUTC": 1461565670022, "id": 200, "message": "OK", "url": "/a/api/questionpro.survey.getAllAccounts" } }



Get Specific Account

Method: questionpro.survey.getAccount

This API call can be used to get a specific account based on userID.

Attributes

Name Value Required
userID User ID

URL

http://api.questionpro.com/a/api/questionpro.survey.getAccount

Sample Request

public String getAccountURL(){ return "http://api.questionpro.com/a/api/questionpro.survey.getAccount?accessKey=" + getAccessKey(); } public JSONObject getAccount() throws Exception { String path = getAccountURL(); DefaultHttpClient httpclient = new DefaultHttpClient(); HttpPost httpost = new HttpPost(path); JSONObject data = new JSONObject(); data.put("userID", getUserID()); StringEntity se = new StringEntity(data.toString()); httpost.setEntity(se); httpost.setHeader("Accept", "application/json"); httpost.setHeader("Content-type", "application/json"); ResponseHandler responseHandler = new BasicResponseHandler(); Object resp = httpclient.execute(httpost, responseHandler); return new JSONObject(resp.toString()); }



Sample Response

{ "response": { "account": { "firstName": "xyz", "lastName": "pqr", "lastLogin": "0 days(s) ago", "emailAddress": "[email protected]", "phone": "(IN)9876543210", "creationDate": "Nov 17, 2010", "userID": 1234 } }, "status": { "method": "questionpro.survey.getAccount", "apiKey": "xxxx", "serverUTC": 1461565902891, "id": 200, "message": "OK", "url": "/a/api/questionpro.survey.getAccount" } }



Get All Surveys

Method: questionpro.survey.getAllSurveys

This API call can be used to get all surveys belonging to a specific user account.

URL

http://api.questionpro.com/a/api/questionpro.survey.getAllSurveys

Sample Request

public String getSurveysURL(){ return "http://api.questionpro.com/a/api/questionpro.survey.getAllSurveys?accessKey=" + getAccessKey(); } public JSONObject getSurveys() throws Exception { String path = getSurveysURL(); DefaultHttpClient httpclient = new DefaultHttpClient(); HttpPost httpost = new HttpPost(path); httpost.setHeader("Accept", "application/json"); httpost.setHeader("Content-type", "application/json"); ResponseHandler responseHandler = new BasicResponseHandler(); Object resp = httpclient.execute(httpost, responseHandler); return new JSONObject(resp.toString()); }



Sample Response

{ "response":{ "surveys:":[ { "surveyID":4794284, "surveyName":"QP (V1.24) CNC Assessment 2016-2017", "surveyURL":"https://www.questionpro.com/a/TakeSurvey?id=4794284" }, { "surveyID":4794283, "surveyName":"(Copy) (V1.24 TEST)", "surveyURL":"https://www.questionpro.com/a/TakeSurvey?id=4794283" } "status":{ "method":"questionpro.survey.getAllSurveys", "serverUTC":1472021401080, "id":200, "message":"OK", "url":"/a/api/questionpro.survey.getAllSurveys" } }



Get Survey

Method: questionpro.survey.getSurvey

This API call can be used to get a specific survey.

Attributes

Name Value Required
id Survey ID

URL

http://api.questionpro.com/a/api/questionpro.survey.getSurvey

Sample Request

public String getSurveyURL(){ return "http://api.questionpro.com/a/api/questionpro.survey.getSurvey?accessKey=" + getAccessKey(); } public JSONObject getSurvey() throws Exception { String path = getSurveyURL(); DefaultHttpClient httpclient = new DefaultHttpClient(); HttpPost httpost = new HttpPost(path); JSONObject data = new JSONObject(); data.put("id", getSurveyID()); StringEntity se = new StringEntity(data.toString()); httpost.setEntity(se); httpost.setHeader("Accept", "application/json"); httpost.setHeader("Content-type", "application/json"); ResponseHandler responseHandler = new BasicResponseHandler(); Object resp = httpclient.execute(httpost, responseHandler); return new JSONObject(resp.toString()); }



Sample Response

{ "response":{ "connectURL":"http://www.questionpro.com/t/AIBHLZVEJR", "subtitle":"Aug 05 2016", "languageContent":[ ], "thankYouMessage":"Thank you for completing this survey.", "surveyLanguages":[ { "isDefault":true, "name":"English" } ], "id":4782051, "hasScoringLogic":false, "title":"CSat Survey", "sections":[ { "numTasks":0, "exactMinAnswers":0, "orientation":2, "code":"Q1", "maxAnswers":0, "questions":[ { "orderNumber":0, "answers":[ { "score":0, "isDefault":false, "excludeRandomize":0, "id":252834875, "text":"Weekly" }, { "score":0, "isDefault":false, "excludeRandomize":0, "id":252834876, "text":"Monthly" }, { "score":0, "isDefault":false, "excludeRandomize":0, "id":252834877, "text":"Quarterly" }, { "score":0, "isDefault":false, "excludeRandomize":0, "id":252834878, "text":"Annually" } ], "id":48612631, "text":"How often do you conduct surveys?" } ], "dynamicExplodeText":"", "sectionID":1, "type":"U", "minAnswers":0, "required":false, "hasPageBreak":false, "random":false, "randomSection":false, "subtype":"A" } ], "surveyTheme":{ "titleBarBGGrad":"#233954", "buttonHoverBG":"#9e9f9f", "surveyBGGrad":"#4f4f4f", "titleBarTextColor":"#ffffff", "buttonTextColor":"#3b3b3b" }, "numericTitle":0 }, "status":{ "method":"questionpro.survey.getSurvey", "serverUTC":1470390437541, "id":200, "message":"OK", "url":"/a/api/questionpro.survey.getSurvey" } }



Delete Survey

Method: questionpro.survey.deleteSurvey

This API call can be used to delete a specific survey.

Attributes

Name Value Required
surveyID Survey ID

URL

http://api.questionpro.com/a/api/questionpro.survey.deleteSurvey

Sample Request

public String deleteSurveyURL(){ return "http://api.questionpro.com/a/api/questionpro.survey.deleteSurvey?accessKey=" + getAccessKey(); } public JSONObject deleteSurvey() throws Exception { String path = deleteSurveyURL(); DefaultHttpClient httpclient = new DefaultHttpClient(); HttpPost httpost = new HttpPost(path); JSONObject data = new JSONObject(); data.put("surveyID", getSurveyID()); StringEntity se = new StringEntity(data.toString()); httpost.setEntity(se); httpost.setHeader("Accept", "application/json"); httpost.setHeader("Content-type", "application/json"); ResponseHandler responseHandler = new BasicResponseHandler(); Object resp = httpclient.execute(httpost, responseHandler); return new JSONObject(resp.toString()); }



Sample Response

{ "response": { "surveyID": 6110, "success": 1, "message": "Survey deleted successfully" }, "status": { "method": "questionpro.survey.deleteSurvey", "apiKey": "xxxx", "serverUTC": 1461566204206, "id": 200, "message": "OK", "url": "/a/api/questionpro.survey.deleteSurvey" } }



Get All Email Lists

Method: questionpro.survey.getEmailLists

This API call can be used to get all email lists for a given survey. It returns global as well as survey-specific list.

Attributes

Name Value Required
surveyID Survey ID

URL

http://api.questionpro.com/a/api/questionpro.survey.getEmailLists

Sample Request

public String getEmailListsURL(){ return "http://api.questionpro.com/a/api/questionpro.survey.getEmailLists?accessKey=" + getAccessKey(); } public JSONObject getEmailLists() throws Exception { String path = getEmailListsURL(); DefaultHttpClient httpclient = new DefaultHttpClient(); HttpPost httpost = new HttpPost(path); JSONObject data = new JSONObject(); data.put("surveyID", getSurveyID()); StringEntity se = new StringEntity(data.toString()); httpost.setEntity(se); httpost.setHeader("Accept", "application/json"); httpost.setHeader("Content-type", "application/json"); ResponseHandler responseHandler = new BasicResponseHandler(); Object resp = httpclient.execute(httpost, responseHandler); return new JSONObject(resp.toString()); }



Sample Response

{ "response": { "emailLists": [ { "surveyID": 0, "name": "my global list", "emailGroupID": 1300, "email": "[email protected], [email protected], [email protected]", "statistics": { "unsubscribed": "3", "total": 3, "active": "0", "pendinVerification": 0, "bounced": "0" } }, { "surveyID": 5395, "name": "Email-List-test", "emailGroupID": 1354, "email": "[email protected]", "statistics": { "unsubscribed": "0", "total": 1, "active": "1", "pendinVerification": 0, "bounced": "0" } }, { "surveyID": 5395, "name": "Default List-1", "emailGroupID": 1355, "email": "", "statistics": { "unsubscribed": "0", "total": 0, "active": "0", "pendinVerification": 0, "bounced": "0" } } ] }, "status": { "method": "questionpro.survey.getEmailLists", "apiKey": "xxxx", "serverUTC": 1461566830499, "id": 200, "message": "OK", "url": "/a/api/questionpro.survey.getEmailLists" } }



Get Specific Email List

Method: questionpro.survey.getEmailList

This API call can be used to get specific email list with requested email group id.

Attributes

Name Value Required
emailGroupID Email Group ID

URL

http://api.questionpro.com/a/api/questionpro.survey.getEmailList

Sample Request

public String getEmailListURL(){ return "http://api.questionpro.com/a/api/questionpro.survey.getEmailList?accessKey=" + getAccessKey(); } public JSONObject getEmailList() throws Exception { String path = getEmailListURL(); DefaultHttpClient httpclient = new DefaultHttpClient(); HttpPost httpost = new HttpPost(path); JSONObject data = new JSONObject(); data.put("emailGroupID", getEmailGroupID()); StringEntity se = new StringEntity(data.toString()); httpost.setEntity(se); httpost.setHeader("Accept", "application/json"); httpost.setHeader("Content-type", "application/json"); ResponseHandler responseHandler = new BasicResponseHandler(); Object resp = httpclient.execute(httpost, responseHandler); return new JSONObject(resp.toString()); }



Sample Response

{ "response": { "emailList": { "surveyID": 5395, "name": "Email-List-test", "emailGroupID": 1354, "email": "[email protected]", "statistics": { "unsubscribed": "0", "total": 1, "active": "1", "pendinVerification": 0, "bounced": "0" } } }, "status": { "method": "questionpro.survey.getEmailList", "apiKey": "xxxx", "serverUTC": 1461567017465, "id": 200, "message": "OK", "url": "/a/api/questionpro.survey.getEmailList" } }



Delete Specific Email List

Method: questionpro.survey.deleteEmailList

This API call can be used to delete specific email list with requested email group id.

Attributes

Name Value Required
emailGroupID Email Group ID

URL

http://api.questionpro.com/a/api/questionpro.survey.deleteEmailList

Sample Request

public String deleteEmailListURL(){ return "http://api.questionpro.com/a/api/questionpro.survey.deleteEmailList?accessKey=" + getAccessKey(); } public JSONObject deleteEmailList() throws Exception { String path = deleteEmailListURL(); DefaultHttpClient httpclient = new DefaultHttpClient(); HttpPost httpost = new HttpPost(path); JSONObject data = new JSONObject(); data.put("emailGroupID", getEmailGroupID()); StringEntity se = new StringEntity(data.toString()); httpost.setEntity(se); httpost.setHeader("Accept", "application/json"); httpost.setHeader("Content-type", "application/json"); ResponseHandler responseHandler = new BasicResponseHandler(); Object resp = httpclient.execute(httpost, responseHandler); return new JSONObject(resp.toString()); }



Sample Response

{ "response": { "success": 1, "message": "Email Group deleted successfully", "emailGroupID": 1354 }, "status": { "method": "questionpro.survey.deleteEmailList", "apiKey": "xxxx", "serverUTC": 1461567218720, "id": 200, "message": "OK", "url": "/a/api/questionpro.survey.deleteEmailList" } }



Get All Email Templates

Method: questionpro.survey.getEmailTemplates

This API call can be used to get all email templates for a given survey.

Attributes

Name Value Required
surveyID Survey ID

URL

http://api.questionpro.com/a/api/questionpro.survey.getEmailTemplates

Sample Request

public String getEmailTemplatesURL(){ return "http://api.questionpro.com/a/api/questionpro.survey.getEmailTemplates?accessKey=" + getAccessKey(); } public JSONObject getEmailTemplates() throws Exception { String path = getEmailTemplatesURL(); DefaultHttpClient httpclient = new DefaultHttpClient(); HttpPost httpost = new HttpPost(path); JSONObject data = new JSONObject(); data.put("surveyID", getSurveyID()); StringEntity se = new StringEntity(data.toString()); httpost.setEntity(se); httpost.setHeader("Accept", "application/json"); httpost.setHeader("Content-type", "application/json"); ResponseHandler responseHandler = new BasicResponseHandler(); Object resp = httpclient.execute(httpost, responseHandler); return new JSONObject(resp.toString()); }



Sample Response

"response": { "emailTemplates": [ { "surveyID": 5395, "templateID": 123, "title": "Test-Survey-Specific", "contentSummary": "Hello,\n\nWe would appreciate your feedback" } ] }, "status": { "method": "questionpro.survey.getEmailTemplates", "apiKey": "xxxx", "serverUTC": 1461567860254, "id": 200, "message": "OK", "url": "/a/api/questionpro.survey.getEmailTemplates" } }



Get Email Template

Method: questionpro.survey.getEmailTemplate

This API call can be used to get a specific email template with requested template id.

Attributes

Name Value Required
templateID Template ID

URL

http://api.questionpro.com/a/api/questionpro.survey.getEmailTemplate

Sample Request

public String getEmailTemplateURL(){ return "http://api.questionpro.com/a/api/questionpro.survey.getEmailTemplate?accessKey=" + getAccessKey(); } public JSONObject getEmailTemplate() throws Exception { String path = getEmailTemplateURL(); DefaultHttpClient httpclient = new DefaultHttpClient(); HttpPost httpost = new HttpPost(path); JSONObject data = new JSONObject(); data.put("templateID", getTemplateID()); StringEntity se = new StringEntity(data.toString()); httpost.setEntity(se); httpost.setHeader("Accept", "application/json"); httpost.setHeader("Content-type", "application/json"); ResponseHandler responseHandler = new BasicResponseHandler(); Object resp = httpclient.execute(httpost, responseHandler); return new JSONObject(resp.toString()); }



Sample Response

{ "response": { "emailTemplate": { "surveyID": 5395, "templateID": 123, "title": "Test-Survey-Specific", "type": "2", "contentSummary": "Hello,\n\nWe would appreciate your feedback" } }, "status": { "method": "questionpro.survey.getEmailTemplate", "apiKey": "xxxx", "serverUTC": 1461567927522, "id": 200, "message": "OK", "url": "/a/api/questionpro.survey.getEmailTemplate" } }



Delete Email Template

Method: questionpro.survey.deleteEmailTemplate

This API call can be used to delete a specific email template with requested template id.

Attributes

Name Value Required
templateID Template ID

URL

http://api.questionpro.com/a/api/questionpro.survey.deleteEmailTemplate

Sample Request

public String deleteEmailTemplateURL(){ return "http://api.questionpro.com/a/api/questionpro.survey.deleteEmailTemplate?accessKey=" + getAccessKey(); } public JSONObject deleteEmailTemplate() throws Exception { String path = deleteEmailTemplateURL(); DefaultHttpClient httpclient = new DefaultHttpClient(); HttpPost httpost = new HttpPost(path); JSONObject data = new JSONObject(); data.put("templateID", getTemplateID()); StringEntity se = new StringEntity(data.toString()); httpost.setEntity(se); httpost.setHeader("Accept", "application/json"); httpost.setHeader("Content-type", "application/json"); ResponseHandler responseHandler = new BasicResponseHandler(); Object resp = httpclient.execute(httpost, responseHandler); return new JSONObject(resp.toString()); }



Sample Response

{ "response": { "success": 1, "templateID": 123, "message": "Email Template deleted successfully" }, "status": { "method": "questionpro.survey.deleteEmailTemplate", "apiKey": "xxxx", "serverUTC": 1461568015962, "id": 200, "message": "OK", "url": "/a/api/questionpro.survey.deleteEmailTemplate" } } }



t

Get Specific Response

Method: questionpro.survey.surveyResponse

This API call can be used to get a specific survey response for a given survey.

Attributes

Name Value Required
surveyID Survey ID
responseID Response ID

URL

http://api.questionpro.com/a/api/questionpro.survey.surveyResponse

Sample Request

public String surveyResponseURL(){ return "http://api.questionpro.com/a/api/questionpro.survey.surveyResponse?accessKey=" + getAccessKey(); } public JSONObject surveyResponse() throws Exception { String path = surveyResponseURL(); DefaultHttpClient httpclient = new DefaultHttpClient(); HttpPost httpost = new HttpPost(path); JSONObject data = new JSONObject(); data.put("surveyID", getSurveyID()); data.put("responseID", getResponseID()); StringEntity se = new StringEntity(data.toString()); httpost.setEntity(se); httpost.setHeader("Accept", "application/json"); httpost.setHeader("Content-type", "application/json"); ResponseHandler responseHandler = new BasicResponseHandler(); Object resp = httpclient.execute(httpost, responseHandler); return new JSONObject(resp.toString()); }



Sample Response

{ "response": { "surveyResponse": { "externalReference": "test_response", "timeTaken": 23, "ipAddress": "127.0.0.1", "UTCTimestamp": 13, "id": 29245, "duplicate": false, "responseStatus": "Yes", "responseSet": [ { "questionDescription": " ", "questionID": 17607029, "questionCode": "Q1", "values": [ { "answerText": "Weekly", "id": "135906", "value": { "scale": "1", "dynamic": "[Weekly]\r\nabc " } } ], "questionText": "How often do you conduct surveys?" } ], "timestamp": "24 Feb, 2016 05:00:13 PM IST" }, "name": "emojiSurvey1", "id": 123, "status": "Active" }, "status": { "method": "questionpro.survey.surveyResponse", "apiKey": "xxxx", "serverUTC": 1461568638389, "id": 200, "message": "OK", "url": "/a/api/questionpro.survey.surveyResponse" } }



Delete a Specific Response

Method: questionpro.survey.deleteResponse

This API call can be used to get a specific survey response for a given survey.

Attributes

Name Value Required
surveyID Survey ID
responseID Response ID

URL

http://api.questionpro.com/a/api/questionpro.survey.deleteResponse

Sample Request

public String deleteResponseURL(){ return "http://api.questionpro.com/a/api/questionpro.survey.deleteResponse?accessKey=" + getAccessKey(); } public JSONObject deleteResponse() throws Exception { String path = deleteResponseURL(); DefaultHttpClient httpclient = new DefaultHttpClient(); HttpPost httpost = new HttpPost(path); JSONObject data = new JSONObject(); data.put("surveyID", getSurveyID()); data.put("responseID", getResponseID()); StringEntity se = new StringEntity(data.toString()); httpost.setEntity(se); httpost.setHeader("Accept", "application/json"); httpost.setHeader("Content-type", "application/json"); ResponseHandler responseHandler = new BasicResponseHandler(); Object resp = httpclient.execute(httpost, responseHandler); return new JSONObject(resp.toString()); }



Sample Response

{ "response": { "surveyID": 123, "success": 1, "message": "Response deleted successfully", "responseID": 4567 }, "status": { "method": "questionpro.survey.deleteResponse", "apiKey": "xxxx", "serverUTC": 1461568860575, "id": 200, "message": "OK", "url": "/a/api/questionpro.survey.deleteResponse" } }



QuestionPro is the leader in online surveys, polls and questionnaires