Get Survey Variable

Get the details of a variable of a survey.

Changes from v1.0

  • The response now shows the ‘surveyId’ property at the top and has the variable inside a ‘variable’ property.
  • The ‘id’ property has been removed from the response.

Endpoint

MethodURL
GETsurveys/{surveyId}/variables/{variableId}

Get the details of the specific variable identified by the variableId path variable of the specific survey identified by the surveyId path variable.

Parameters

Path parameters

Path parameterDescription
{surveyId}The id of the survey. This is the survey GUID and not the Interview URL.
{variableId}The unique V number of the variable.
This is the variable Id property returned in the Get Survey Variables end-point.

Query string parameters

None

Sample Request

curl --location --request GET 'http://localhost/snaponline/api/surveys/e819df57-0a01-4592-a7aa-8918dbe54e00/variables/V46' \
--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:

{
    "surveyId": "6834a5f1-46e5-4b12-9e0c-a38a3d9be12c",
    "variable": {
        "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"
            }
        ]
    }
}

Response Definitions

Response Item Description Data Type
surveyIdThe survey Id.String: containing GUID
variableThe variable.Object
variable/orderThe positional order of the variable.Integer
variable/variableIdThe V number of the variableString
variable/labelThe label of the variable.String
variable/nameThe name of the variable.String
variable/questionTextThe question text of the variable. i.e. the question shown to the respondent.String
variable/variableTypeIdThe numeric code for the variable type.Integer:
Unknown = 0, Precoded = 1, Numeric = 2, Alphanumeric = 3, Derived = 5, Question = 6, Note = 7
variable/responseTypeIdThe numeric code for the response type.Integer:  
Unknown = 0, Single = 1, Multiple = 2, Quantity = 3, Literal = 4, None = 5, Date = 6, Time = 7
variable/variableTypeThe type of the variable.String:  
“Unknown”, “Precoded”, “Numeric”, “Alphanumeric”, “Derived”, “Question”, “Note”.
variable/responseTypeThe response type of the answer.String:
“Unknown”, “Single”, “Multiple”, “Quantity”, “Literal”, “None”, “Date”, “Time”
variable/codeCountIf a choice question this states the number of codes. If not a choice question then this will be 0.Integer
variable/codesA list of codes.List: containing objects
variable/codes/codeIndexThe index of the variable code.Integer
variable/codes/codeValueThe value of the variable code.Integer
variable/codes/codeLabelThe label of the variable code.String

HTTP Status Codes

  • 200 OK
  • 404 Not Found – if survey variable does not exist.

Other API calls

Contents