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

Example Request

https://{{env}}.questionpro.com/a/api/v2/surveys/{{survey-id}}/analytics?apiKey={{apiKey}}

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

Authorization

arrow_rightKey - apiKey
  • Name: apiKey
  • Location: query

Request Parameters

arrow_rightPath Parameters
survey-id integer
required

Request Body

arrow_rightPayload
application/json

                    {}
                    

Example Code

arrow_rightcURL
application/json

               curl --request POST 'https://{{env}}.questionpro.com/a/api/v2/surveys/{{survey-id}}/analytics?apiKey={{apiKey}}' \
                    --header 'Content-Type: application/json' \
                    --data-raw '{}'
                
arrow_rightPython
application/json

                    import requests
                    import json
                    
                    url = "https://{{env}}.questionpro.com/a/api/v2/surveys/{{survey-id}}/analytics"
                    
                    querystring = {"apiKey":"{{apiKey}}"}
                    
                    payload = json.dumps({})
                    headers = {
                      'Content-Type': 'application/json'
                    }
                    
                    response = requests.request("POST", url, headers=headers, data=payload)
                    
                    print(response.text) 
                    
arrow_rightPHP
application/json

                <?php

                    $curl = curl_init();
                    
                    curl_setopt_array($curl, array(
                      CURLOPT_URL => 'https://{{env}}.questionpro.com/a/api/v2/surveys/{{survey-id}}/analytics?apiKey={{apiKey}}',
                      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(
                        'Content-Type: application/json'
                      ),
                    ));
                    
                    $response = curl_exec($curl);
                    
                    curl_close($curl);
                    echo $response;

                    

Responses

arrow_rightExample
application/json

                   {
                    "response": {
                    "sections": [
                                    {
                                    "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\\\"><{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
                                        }
                                    ]
                                },
                                {
                                    "title": "What do you look for when purchasing any OTT subscription?",
                                    "questions": [
                                        {
                                            "type": "multiplechoice_checkbox",
                                            "code": "Q2",
                                            "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\":[\"Smart recommendations\",\"Watchlist\",\"Content variety\",\"Multiple user accounts\"],\"title\":{\"text\":\"\"},\"labels\":{\"useHTML\":false,\"style\":{\"style\":{\"fontSize\":\"12px\"}}}},\"credits\":{\"enabled\":false},\"legend\":{\"enabled\":false},\"series\":[{\"data\":[{\"truncatedName\":\"Smart recommendation...\",\"visible\":true,\"name\":\"Smart recommendations\",\"y\":14,\"truncatedDataLabelName\":\"Smart recommendations\",\"percentageValue\":14},{\"truncatedName\":\"Content variety\",\"visible\":true,\"name\":\"Content variety\",\"y\":16,\"truncatedDataLabelName\":\"Content variety\",\"percentageValue\":16},{\"sliced\":true,\"truncatedName\":\"Multiple user accoun...\",\"visible\":true,\"name\":\"Multiple user accounts\",\"y\":70,\"truncatedDataLabelName\":\"Multiple user accounts\",\"percentageValue\":70,\"selected\":true}],\"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\":\"119010700_2_1\",\"style\":{\"fontFamily\":\"Arial\"},\"type\":\"pie\",\"height\":400},\"colors\":[\"# 7D7D7D\",\"# 7D7D7D\",\"# 008fd3\"]}",
                                            "required": false,
                                            "answers": [
                                                {
                                                    "title": "Smart recommendations",
                                                    "count": 14.0,
                                                    "percentage": 14.0
                                                },
                                                {
                                                    "title": "Watchlist",
                                                    "count": 0.0,
                                                    "percentage": 0.0
                                                },
                                                {
                                                    "title": "Content variety",
                                                    "count": 16.0,
                                                    "percentage": 16.0
                                                },
                                                {
                                                    "title": "Multiple user accounts",
                                                    "count": 70.0,
                                                    "percentage": 70.0
                                                }
                                            ],
                                            "id": 119010700
                                        }
                                    ]
                                }
                            ]
                        }
                    }
                   
                    
arrow_rightSchema
application/json
{
  "$schema": "http://json-schema.org/draft-06/schema# ",
  "type": "object",
  "properties": {
    "response": {
      "type": "object",
      "properties": {
        "sections": {
          "type": "array",
          "items": {
            "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": [
        "sections"
      ]
    }
  },
  "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