Get Survey Variables
Get details of all of the variables for a survey.
Changes from v1.0
- A new ‘includeCodes’ query parameter has been added. If the ‘includeCodes’ query parameter is omitted, or if it is set to true, then the response body will include a list of codes for the variable. Each code will contain a ‘codeIndex’, ‘codeValue’ and ‘codeLabel’ property.
- The response now shows the ‘surveyId’ property at the top and has the variables inside a ‘variable’ property.
- The ‘id’ property has been removed from the response.
Endpoint
Method | URL |
---|---|
GET | surveys/{surveyId}/variables |
Gets the details for a specific survey ID.
Parameters
Path parameters
Path parameter | Description |
---|---|
{surveyId} | The id of the survey. This is the survey GUID and not the Interview URL. |
Query string parameters
Query string parameter | Required / Optional | Description | Type | Range | Default |
---|---|---|---|---|---|
includeCodes | Optional | Whether to return code information for the variable in the response. | Boolean | N/A | true |
Sample Request
curl --location --request GET 'http://<servername>/snaponline/api/surveys/e819df57-0a01-4592-a7aa-8918dbe54e00/variables' \
--header 'X-USERNAME: {USERNAME}' \
--header 'X-API-KEY: {APIKEY}' \
--header 'X-VERSION: 2.0'
(In the above code, replace {APIKEY} with your actual API key and {USERNAME} with your actual username.)
Sample Response
200 OK with body (when ‘includeCodes’ is false):
{
"surveyId": "6834a5f1-46e5-4b12-9e0c-a38a3d9be12c",
"variables": [
{
"order": 14,
"variableId": "V46",
"label": "What was the main form of transport used to get to the at...",
"name": "Q1",
"questionText": "What was the main form of transport used to get to the attraction?",
"variableTypeId": 6,
"responseTypeId": 1,
"variableType": "Question",
"responseType": "Single",
"codeCount": 7
},
{
"order": 15,
"variableId": "V48",
"label": "Which facilities did you visit?",
"name": "Q2",
"questionText": "Which facilities did you visit?",
"variableTypeId": 6,
"responseTypeId": 2,
"variableType": "Question",
"responseType": "Multiple",
"codeCount": 3
},
{
"order": 16,
"variableId": "V52",
"label": "Please tell us if there were any issues, otherwise leave ...",
"name": "Q3",
"questionText": "Please tell us if there were any issues, otherwise leave blank.",
"variableTypeId": 6,
"responseTypeId": 4,
"variableType": "Question",
"responseType": "Literal",
"codeCount": 0
}
]
}
200 OK with body (when ‘includeCodes’ is true):
{
"surveyId": "6834a5f1-46e5-4b12-9e0c-a38a3d9be12c",
"variables": [
{
"order": 14,
"variableId": "V46",
"label": "What was the main form of transport used to get to the at...",
"name": "Q1",
"questionText": "What was the main form of transport used to get to the attraction?",
"variableTypeId": 6,
"responseTypeId": 1,
"variableType": "Question",
"responseType": "Single",
"codeCount": 7,
"codes": [
{
"codeIndex": 1,
"codeValue": 3,
"codeLabel": "Walk"
},
{
"codeIndex": 2,
"codeValue": 5,
"codeLabel": "Bike"
},
{
"codeIndex": 3,
"codeValue": 8,
"codeLabel": "Motorbike"
},
{
"codeIndex": 4,
"codeValue": 4,
"codeLabel": "Car"
},
{
"codeIndex": 5,
"codeValue": 6,
"codeLabel": "Bus"
},
{
"codeIndex": 6,
"codeValue": 9,
"codeLabel": "Train"
},
{
"codeIndex": 7,
"codeValue": 10,
"codeLabel": "Plane"
}
]
},
{
"order": 15,
"variableId": "V48",
"label": "Which facilities did you visit?",
"name": "Q2",
"questionText": "Which facilities did you visit?",
"variableTypeId": 6,
"responseTypeId": 2,
"variableType": "Question",
"responseType": "Multiple",
"codeCount": 3,
"codes": [
{
"codeIndex": 1,
"codeValue": 1,
"codeLabel": "Restaurant / Cafe"
},
{
"codeIndex": 2,
"codeValue": 2,
"codeLabel": "Gift Shop"
},
{
"codeIndex": 3,
"codeValue": 3,
"codeLabel": "Customer Services"
}
]
},
{
"order": 16,
"variableId": "V52",
"label": "Please tell us if there were any issues, otherwise leave ...",
"name": "Q3",
"questionText": "Please tell us if there were any issues, otherwise leave blank.",
"variableTypeId": 6,
"responseTypeId": 4,
"variableType": "Question",
"responseType": "Literal",
"codeCount": 0,
"codes": []
}
]
}
Response Definitions
Response Item | Description | Data Type |
---|---|---|
surveyId | The survey Id. | String: containing GUID |
variables | The list of variables. | List: containing objects |
variables/order | The positional order of the variable. | Integer |
variables/variableId | The V number of the variable | String |
variables/label | The label of the variable. | String |
variables/name | The name of the variable. | String |
variables/questionText | The question text of the variable. i.e. the question shown to the respondent. | String |
variables/variableTypeId | The numeric code for the variable type. | Integer: Unknown = 0, Precoded = 1, Numeric = 2, Alphanumeric = 3, Derived = 5, Question = 6, Note = 7 |
variables/responseTypeId | The numeric code for the response type. | Integer: Unknown = 0, Single = 1, Multiple = 2, Quantity = 3, Literal = 4, None = 5, Date = 6, Time = 7 |
variables/variableType | The type of the variable. | String: “Unknown”, “Precoded”, “Numeric”, “Alphanumeric”, “Derived”, “Question”, “Note”. |
variables/responseType | The response type of the answer. | String: “Unknown”, “Single”, “Multiple”, “Quantity”, “Literal”, “None”, “Date”, “Time” |
variables/codeCount | If a choice question this states the number of codes. If not a choice question then this will be 0. | Integer |
variables/codes | A list of variable codes. This section will only appear if the ‘includeCodes’ query parameter is true or omitted AND the variable is a choice question. | List: containing Objects |
variables/codes/codeIndex | The index of the variable code. | Integer |
variables/codes/codeValue | The value of the variable code. | Integer |
variables/codes/codeLabel | The label of the variable code. | String |
HTTP Status Codes
- 200 OK
Other API calls
- Get Survey List
- Get Survey
- Get Survey Variable
- Get Survey Responses
- Get User Info
- Get Participant List
- Get Participant
- Add Participant
- Update Participant
- Delete Participant
- Get Participants Subjects
- Get Participant Subject
- Add Participant Subject
- Update Participant Subject
- Delete Participant Subject