En español
NIDA

Developers API

Revised October 2012

Description

To get the first question.

URL: <URLBASE>/get_question

Logic

When the user request recieved, the presence and validity of the token_id is checked. If the token_id is a valid one, first question with all its sub questions and options will be returned. 

Sample Request Format

{
"key": "qtye456ceger", 
"token_id" : "556"
}

Params 

token_id required
key required

 

Method 

 

(GET|POST)

Sample Response

{
  "status": 1,
  "question": {
    "question_id": 1,
    "description": "In the past year, how often have you used the following?",
    "comment": null,
    "sub_questions": [
      {
        "name":"Alcohol ",
        "description":"For men, 5 or more drinks a day. For women, 4 or more drinks a day"
        "sub_question_id": 1
      },
      {
        "name": "Tobacco Products",
        "sub_question_id": 2
      },
      {
        "name": "Prescription Drugs for Non-Medical Reasons",
        "sub_question_id": 3
      },
      {
        "name": "Illegal Drugs",
        "sub_question_id": 4
      }
    ],
    "options": [
      {
        "name": "Never",
        "option_id": 1
      },
      {
        "name": "Once or Twice",
        "option_id": 2
      },
      {
        "name": "Monthly",
        "option_id": 3
      },
      {
        "name": "Weekly",
        "option_id": 4
      },
      {
        "name": "Daily or Almost Daily",
        "option_id": 5
      }
    ]
  }
}

Response fields

status Status of the API request
errors Errors if any
messages Messages if any
question Includes question_id, description, comments if any, sub questions and its options
sub_questions An array which includes all the sub questions of the current question. Each sub question has its sub_question_id and name.
options An array which includes all the option of the current question.Each option has an option_id and name.

 

This page was last updated October 2012