https://api.questionpro.{{env}}/a/api/v2/surveys/{{survey-id}}/logic-graph
The value of environment {{env}} variable depends upon your datacenter. Refer to the Environment page for more details.
Enumerates every unique logical path through the survey identified by survey-id. The server traverses the survey's branching rules and returns an ordered list of PathStep objects for each possible route a respondent can take. Each step identifies the section visited (sectionId) and the answer that triggered the next branch (answerId; 0 when the transition is unconditional).
curl --location 'https://api.questionpro.{{env}}/a/api/v2/surveys/{{survey-id}}/logic-graph' \
--header 'Accept: application/json' \
--header 'api-key: {{api-key}}'
import requests
url = "https://api.questionpro.{{env}}/a/api/v2/surveys/{{survey-id}}/logic-graph"
headers = {
"Accept": "application/json",
"api-key": "{{api-key}}"
}
response = requests.get(url, headers=headers)
data = response.json()
total_paths = data["response"]["totalPaths"]
paths = data["response"]["paths"]
for index, path in enumerate(paths):
print("Path " + str(index + 1) + ":")
for step in path:
print(" sectionId=" + str(step["sectionId"]) + " answerId=" + str(step["answerId"]))
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://api.questionpro.{{env}}/a/api/v2/surveys/{{survey-id}}/logic-graph',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'GET',
CURLOPT_HTTPHEADER => array(
'Accept: application/json',
'api-key: {{api-key}}'
),
));
$response = curl_exec($curl);
curl_close($curl);
$data = json_decode($response, true);
$totalPaths = $data['response']['totalPaths'];
$paths = $data['response']['paths'];
foreach ($paths as $i => $path) {
echo "Path " . ($i + 1) . ":\n";
foreach ($path as $step) {
echo " sectionId=" . $step['sectionId'] . " answerId=" . $step['answerId'] . "\n";
}
}
const response = await fetch(
'https://api.questionpro.{{env}}/a/api/v2/surveys/{{survey-id}}/logic-graph',
{
method: 'GET',
headers: {
'Accept': 'application/json',
'api-key': '{{api-key}}'
}
}
);
const data = await response.json();
const totalPaths = data.response.totalPaths;
const paths = data.response.paths;
paths.forEach(function(path, index) {
console.log('Path ' + (index + 1) + ':');
path.forEach(function(step) {
console.log(' sectionId=' + step.sectionId + ' answerId=' + step.answerId);
});
});
{
"response": {
"totalPaths": 3,
"paths": [
[
{ "sectionId": 10001, "answerId": 50001 },
{ "sectionId": 10003, "answerId": 0 },
{ "sectionId": 10005, "answerId": 0 }
],
[
{ "sectionId": 10001, "answerId": 50002 },
{ "sectionId": 10002, "answerId": 0 },
{ "sectionId": 10005, "answerId": 0 }
],
[
{ "sectionId": 10001, "answerId": 50003 },
{ "sectionId": 10004, "answerId": 0 },
{ "sectionId": 10005, "answerId": 0 }
]
]
},
"requestID": "8012fedc-e8ce-48ae-b800-6q5ce287987a"
}
{
"$schema": "http://json-schema.org/draft-06/schema# ",
"type": "object",
"properties": {
"response": {
"type": "object",
"properties": {
"totalPaths": {
"type": "string"
},
"paths": {
"type": "array",
"items": {
"type": "array",
"items": {
"type": "object",
"properties": {
"answerId": {
"type": "string"
},
"sectionId": {
"type": "string"
}
},
"additionalProperties": false,
"required": [
"answerId",
"sectionId"
]
}
}
}
},
"additionalProperties": false,
"required": [
"totalPaths",
"paths"
]
},
"requestID": {
"type": "string"
}
},
"additionalProperties": false,
"required": [
"response",
"requestID"
]
}
{
"response": {
"totalPaths": 1,
"paths": [
[
{ "sectionId": 10001, "answerId": 0 },
{ "sectionId": 10002, "answerId": 0 },
{ "sectionId": 10003, "answerId": 0 }
]
]
},
"requestID": "8012fedc-e8ce-48ae-b800-6q5ce287987a"
}
{
"response": {
"totalPaths": 0,
"paths": []
},
"requestID": "8012fedc-e8ce-48ae-b800-6q5ce287987a"
}
{
"response": {
"error": {
"docs": www.questionpro.com/api/error-codes.html
"name": "BAD_REQUEST",
"httpStatusCode": 400,
"id" : "1000",
"message": "Invalid URL parameters",
"resourceUrl":"resource_url"
}
}
}
{
"$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"
]
}
{
"response": {
"error": {
"docs": www.questionpro.com/api/error-codes.html
"name": "UNAUTHORIZED",
"httpStatusCode": 401,
"id" : "1010",
"message": "Incorrect API Key",
"resourceUrl":"resource_url"
}
}
}
{
"$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"
]
}
{
"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"
}
}
}
{
"$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"
]
}
{
"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"
}
}
}
{
"$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"
]
}
{
"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"
}
}
}
{
"$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"
]
}