Post /surveys/{{survey-id}}/questions/{{question-id}}/analytics

Example Request

https://api.questionpro.{{env}}/a/api/v2/surveys/{{survey-id}}/questions/{{question-id}}/analytics

The value of environment {{env}} variable depends upon your datacenter. Refer to the Environment page for more details.


Authorization

arrow_rightSecurity - API Key
Name : api-key
required
Location : Request Header
Type : string

Request Parameters

arrow_rightPath Parameters
survey-id integer
required
question-id integer
required

Request Body

arrow_rightPayload
application/json

                    {}
                    

Example Code

arrow_rightcURL
Snippet copied successfully.
application/json

curl --location 'https://api.questionpro.{{env}}/a/api/v2/surveys/{{survey-id}}/questions/{{question-id}}/analytics' \
--header 'api-key: {{api-key}}' \
--header 'Content-Type: application/json' \
--data '{}'
                
arrow_rightPython
Snippet copied successfully.
application/json

import requests
import json

url = "https://api.questionpro.{{env}}/a/api/v2/surveys/{{survey-id}}/questions/{{question-id}}/analytics"

payload = json.dumps({})
headers = {
  'api-key': '{{api-key}}',
  'Content-Type': 'application/json'
}

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)

                    
arrow_rightPHP - cURL
Snippet copied successfully.
application/json

<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://api.questionpro.{{env}}/a/api/v2/surveys/{{survey-id}}/questions/{{question-id}}/analytics',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS =>'{}',
  CURLOPT_HTTPHEADER => array(
    'api-key: {{api-key}}',
    'Content-Type: application/json'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;


                    

Responses

arrow_rightExample
application/json

                   {
                        "response": {
                            "title": "As per your view, which is the best OTT platform?",
                            "questions": [
                                {
                                    "type": "multiplechoice_radio",
                                    "code": "Q1",
                                    "totalCount": 100.0,
                                    "averageScore": 0.0,
                                    "percentageTotal": 100.0,
                                    "highChartJSON": "{\"plotOptions\":{\"cursor\":\"pointer\",\"bar\":{\"colorByPoint\":true},\"series\":{\"dataLabels\":{\"connectorColor\":\"# 000000\",\"color\":\"# 000000\",\"format\":\"{point.truncatedDataLabelName} : {point.percentageValue:.2f}%\",\"enabled\":true},\"fillOpacity\":0.85,\"animation\":true},\"column\":{\"dataLabels\":{\"crop\":false,\"enabled\":true},\"borderWidth\":0,\"plotPadding\":0.20000000298023224,\"colorByPoint\":true},\"pie\":{\"dataLabels\":{\"style\":{\"width\":\"400px\"}},\"size\":\"80%\",\"allowPointSelect\":true,\"colorByPoint\":true}},\"yAxis\":{\"allowDecimals\":false,\"visible\":true,\"min\":0,\"max\":100,\"title\":{\"text\":\"\"}},\"exporting\":{\"enabled\":false},\"xAxis\":{\"categories\":[\"Netflix\",\"Prime Video\",\"Disney +\"],\"title\":{\"text\":\"\"},\"labels\":{\"useHTML\":false,\"style\":{\"style\":{\"fontSize\":\"12px\"}}}},\"credits\":{\"enabled\":false},\"legend\":{\"enabled\":false},\"series\":[{\"data\":[{\"truncatedName\":\"Netflix\",\"visible\":true,\"name\":\"Netflix\",\"y\":21,\"truncatedDataLabelName\":\"Netflix\",\"percentageValue\":21},{\"sliced\":true,\"truncatedName\":\"Prime Video\",\"visible\":true,\"name\":\"Prime Video\",\"y\":44,\"truncatedDataLabelName\":\"Prime Video\",\"percentageValue\":44,\"selected\":true},{\"truncatedName\":\"Disney +\",\"visible\":true,\"name\":\"Disney +\",\"y\":35,\"truncatedDataLabelName\":\"Disney +\",\"percentageValue\":35}],\"name\":\"\"}],\"subtitle\":{\"text\":\"\"},\"tooltip\":{\"shared\":true,\"headerFormat\":\"<span style=\\\"font-size:10px\\\"><\/span><table>\",\"valueDecimals\":0,\"useHTML\":true,\"pointFormat\":\"<tr><td style=\\\"padding:0\\\"><b>{point.name} : {point.percentageValue:.2f}%<\/b><\/td><\/tr>\",\"footerFormat\":\"<\/table>\"},\"title\":{\"text\":\"\"},\"chart\":{\"renderTo\":\"119010698_1_1\",\"style\":{\"fontFamily\":\"Arial\"},\"type\":\"pie\",\"height\":400},\"colors\":[\"# 7D7D7D\",\"# 008fd3\",\"# 7D7D7D\"]}",
                                    "required": false,
                                    "answers": [
                                        {
                                            "title": "Netflix",
                                            "count": 21.0,
                                            "percentage": 21.0
                                        },
                                        {
                                            "title": "Prime Video",
                                            "count": 44.0,
                                            "percentage": 44.0
                                        },
                                        {
                                            "title": "Disney +",
                                            "count": 35.0,
                                            "percentage": 35.0
                                        }
                                    ],
                                    "id": 119010698
                                }
                            ]
                        }
                    }
                    
arrow_rightSchema
application/json
{
  "$schema": "http://json-schema.org/draft-06/schema# ",
  "type": "object",
  "properties": {
    "response": {
      "type": "object",
      "properties": {
        "questions": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string"
              },
              "answers": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "percentage": {
                      "type": "number"
                    },
                    "count": {
                      "type": "number"
                    },
                    "title": {
                      "type": "string"
                    }
                  },
                  "additionalProperties": false,
                  "required": [
                    "percentage",
                    "count",
                    "title"
                  ]
                }
              },
              "highChartJSON": {
                "type": "string"
              },
              "id": {
                "type": "integer"
              },
              "type": {
                "type": "string"
              },
              "totalCount": {
                "type": "number"
              },
              "percentageTotal": {
                "type": "number"
              },
              "required": {
                "type": "boolean"
              },
              "averageScore": {
                "type": "number"
              }
            },
            "additionalProperties": false,
            "required": [
              "code",
              "answers",
              "highChartJSON",
              "id",
              "type",
              "totalCount",
              "percentageTotal",
              "required",
              "averageScore"
            ]
          }
        },
        "title": {
          "type": "string"
        }
      },
      "additionalProperties": false,
      "required": [
        "questions",
        "title"
      ]
    }
  },
  "additionalProperties": false,
  "required": [
    "response"
  ]
}
arrow_right400 example
application/json

{
    "response": {
     "error": {
         "docs": www.questionpro.com/api/error-codes.html
         "name": "BAD_REQUEST",
         "httpStatusCode": 400,
         "id" : "1000",
         "message": "Invalid URL parameters",
         "resourceUrl":"resource_url"
        }
    }
}
                                
arrow_rightSchema
application/json

{
  "$schema": "http://json-schema.org/draft-06/schema#                                 ",
  "type": "object",
  "properties": {
    "response": {
      "type": "object",
      "properties": {
        "error": {
          "type": "object",
          "properties": {
            "docs": {
              "type": "string"
            },
            "resourceUrl": {
              "type": "string"
            },
            "name": {
              "type": "string"
            },
            "id": {
              "type": "string"
            },
            "message": {
              "type": "string"
            },
            "httpStatusCode": {
              "type": "integer"
            }
          },
          "additionalProperties": false,
          "required": [
            "docs",
            "resourceUrl",
            "name",
            "id",
            "message",
            "httpStatusCode"
          ]
        }
      },
      "additionalProperties": false,
      "required": [
        "error"
      ]
    }
  },
  "additionalProperties": false,
  "required": [
    "response"
  ]
}
                                
arrow_right401 example
application/json

{
    "response": {
     "error": {
         "docs": www.questionpro.com/api/error-codes.html
         "name": "UNAUTHORIZED",
         "httpStatusCode": 401,
         "id" : "1010",
         "message": "Incorrect API Key",
         "resourceUrl":"resource_url"
        }
    }
}
						
							
arrow_rightSchema
application/json

{
  "$schema": "http://json-schema.org/draft-06/schema#                                 ",
  "type": "object",
  "properties": {
    "response": {
      "type": "object",
      "properties": {
        "error": {
          "type": "object",
          "properties": {
            "docs": {
              "type": "string"
            },
            "resourceUrl": {
              "type": "string"
            },
            "name": {
              "type": "string"
            },
            "id": {
              "type": "string"
            },
            "message": {
              "type": "string"
            },
            "httpStatusCode": {
              "type": "integer"
            }
          },
          "additionalProperties": false,
          "required": [
            "docs",
            "resourceUrl",
            "name",
            "id",
            "message",
            "httpStatusCode"
          ]
        }
      },
      "additionalProperties": false,
      "required": [
        "error"
      ]
    }
  },
  "additionalProperties": false,
  "required": [
    "response"
  ]
}
                                
arrow_right403 example
application/json

{
    "response": {
     "error": {
         "docs": www.questionpro.com/api/error-codes.html
         "name": "FORBIDDEN",
         "httpStatusCode": 403,
         "id" : "1013",
         "message": "The user does not have permission to access the resource",
         "resourceUrl":"resource_url"
        }
    }
}				
							
arrow_rightSchema
application/json

{
  "$schema": "http://json-schema.org/draft-06/schema#                                 ",
  "type": "object",
  "properties": {
    "response": {
      "type": "object",
      "properties": {
        "error": {
          "type": "object",
          "properties": {
            "docs": {
              "type": "string"
            },
            "resourceUrl": {
              "type": "string"
            },
            "name": {
              "type": "string"
            },
            "id": {
              "type": "string"
            },
            "message": {
              "type": "string"
            },
            "httpStatusCode": {
              "type": "integer"
            }
          },
          "additionalProperties": false,
          "required": [
            "docs",
            "resourceUrl",
            "name",
            "id",
            "message",
            "httpStatusCode"
          ]
        }
      },
      "additionalProperties": false,
      "required": [
        "error"
      ]
    }
  },
  "additionalProperties": false,
  "required": [
    "response"
  ]
}
                                
arrow_right404 example
application/json

{
    "response": {
     "error": {
         "docs": www.questionpro.com/api/error-codes.html
         "name": "NOT_FOUND",
         "httpStatusCode": 404,
         "id" : "1040",
         "message": "The resource that you're trying to access doesn't exist",
         "resourceUrl":"resource_url"
        }
    }
}
							
							
arrow_rightSchema
application/json

{
  "$schema": "http://json-schema.org/draft-06/schema#                                 ",
  "type": "object",
  "properties": {
    "response": {
      "type": "object",
      "properties": {
        "error": {
          "type": "object",
          "properties": {
            "docs": {
              "type": "string"
            },
            "resourceUrl": {
              "type": "string"
            },
            "name": {
              "type": "string"
            },
            "id": {
              "type": "string"
            },
            "message": {
              "type": "string"
            },
            "httpStatusCode": {
              "type": "integer"
            }
          },
          "additionalProperties": false,
          "required": [
            "docs",
            "resourceUrl",
            "name",
            "id",
            "message",
            "httpStatusCode"
          ]
        }
      },
      "additionalProperties": false,
      "required": [
        "error"
      ]
    }
  },
  "additionalProperties": false,
  "required": [
    "response"
  ]
}
                                
arrow_right500 example
application/json

{
    "response": {
     "error": {
         "docs": www.questionpro.com/api/error-codes.html
         "name": "INTERNAL_SERVER_ERROR",
         "httpStatusCode": 500,
         "id" : "1026",
         "message": "We are not able to process your request",
         "resourceUrl":"resource_url"
        }
    }
}
							
arrow_rightSchema
application/json

{
  "$schema": "http://json-schema.org/draft-06/schema#                                 ",
  "type": "object",
  "properties": {
    "response": {
      "type": "object",
      "properties": {
        "error": {
          "type": "object",
          "properties": {
            "docs": {
              "type": "string"
            },
            "resourceUrl": {
              "type": "string"
            },
            "name": {
              "type": "string"
            },
            "id": {
              "type": "string"
            },
            "message": {
              "type": "string"
            },
            "httpStatusCode": {
              "type": "integer"
            }
          },
          "additionalProperties": false,
          "required": [
            "docs",
            "resourceUrl",
            "name",
            "id",
            "message",
            "httpStatusCode"
          ]
        }
      },
      "additionalProperties": false,
      "required": [
        "error"
      ]
    }
  },
  "additionalProperties": false,
  "required": [
    "response"
  ]
}
                                

Unsupported Question Types

arrow_rightBasic
Static Content - Presentation text, section heading, section sub-heading
Basic Matrix - Spreadsheet
arrow_rightAdvanced
Image / Multimedia: TubePulse, HeatMap
Health Care: Verified Signature
Data Reference: Store Locator, Custom Numeric Validator
Mobile: QR Code - Like/Dislike
Upload: Attach/Upload File, Signature, Live Cast
Logic: Custom Logic Engine
Misc: Page Timer