Snap XMP Help

Get Survey Variables

You are here:
< All Topics

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

MethodURL
GETsurveys/{surveyId}/variables

Gets the details for a specific survey ID.

Parameters

Path parameters

Path parameterDescription
{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
includeCodesOptionalWhether to return code information for the variable in the response.BooleanN/Atrue

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
surveyIdThe survey Id.String: containing GUID
variablesThe list of variables.List: containing objects
variables/orderThe positional order of the variable.Integer
variables/variableIdThe V number of the variableString
variables/labelThe label of the variable.String
variables/nameThe name of the variable.String
variables/questionTextThe question text of the variable. i.e. the question shown to the respondent.String
variables/variableTypeIdThe numeric code for the variable type.Integer:

Unknown = 0, Precoded = 1, Numeric = 2, Alphanumeric = 3, Derived = 5, Question = 6, Note = 7
variables/responseTypeIdThe numeric code for the response type.Integer:   Unknown = 0, Single = 1, Multiple = 2, Quantity = 3, Literal = 4, None = 5, Date = 6, Time = 7
variables/variableTypeThe type of the variable.String:   “Unknown”, “Precoded”, “Numeric”, “Alphanumeric”, “Derived”, “Question”, “Note”.
variables/responseTypeThe response type of the answer.String:

“Unknown”, “Single”, “Multiple”, “Quantity”, “Literal”, “None”, “Date”, “Time”
variables/codeCountIf a choice question this states the number of codes. If not a choice question then this will be 0.Integer
variables/codesA 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/codeIndexThe index of the variable code.Integer
variables/codes/codeValueThe value of the variable code.Integer
variables/codes/codeLabelThe label of the variable code.String

HTTP Status Codes

  • 200 OK

Other API calls

Contents