REST API
V3
SurveyLab umożliwia dostęp do Twoich ankiet i danych za pomocą REST API. Dostęp do API odbywa się za pomocą szyfrowanego połączenia (SSL / HTTPS) oraz tokenu. Dane są udostępniane w formacie JSON. Autoryzacja użytkownika odbywa się za pomocą JWT.
UWAGI. Aby skorzystać z API będziesz potrzebować clientId oraz clientSecret. Te informacje są udostępniane na żądanie. Skontaktuj się z nami, aby je uzyskać.
Lista dostępnych zapytań:
Kody statusów
Statusy są zwracane za pomocą standardowych kodów błędów HTTPS.
Kod |
Opis |
200 |
OK. Zapytania zostało wykonane pomyślnie. |
400 |
Bad request. Zapytanie nie powiodło się. Błędny token. |
401 |
Unauthorized. Próbujesz zautoryzować się za pomocą błędnego loginu lub klucza API. |
404 |
Not Found. Zasób nie istnieje. |
500 |
Internal Server Error. Spróbuj ponownie lub skontaktuj się z naszym wsparciem. |
Pobierz token
Pobranie tokena do bezpiecznej komunikacji. Token jest ważny przez 30 dni.
POST https://api.surveylab.com/oauth/token/
cURL
curl -i -X POST https://api.surveylab.com/oauth/token/ -d "clientSecret=YOUR_CLIENT_SECRET&clientId=YOUR_CLIENT_ID"
Przykład wyniku zapytania
JWT Token
Pobierz listę ankiet
Pobranie listy ankiet. Otrzymasz listę wszystkich ankiet znajdujących się na Twoim koncie.
GET https://api.surveylab.com/api/v3/surveys/
cURL
curl -i -X GET -H "Authorization:bearer YOUR_ACCESS_TOKEN" -H "Content-Type": "application/json" https://api.surveylab.com/api/v3/surveys/
Przykład
https://api.surveylab.com/api/v3/surveys/
Przykład wyniku zapytania
[{
"surveyId": 22789,
"userId": 127,
"surveyThemeId": 90,
"name": "eNPS",
"questionNumbering": "survey",
"headerPageTitleShow": null,
"headerPageNumberShow": null,
"pageRotation": 0,
"logoPlacement": null,
"layoutHideProgressBar": null,
"created": 1540556695,
"modified": "2019-01-03 15:14:45",
"footerVisible": null,
"headerShowTitle": null,
"answerOneClick": null,
"logoVisibility": null,
"logoVisibilityEmbedded": null,
"logoURL": null,
"blockRotation": 0,
"defaultName": "eNPS",
"languageId": 2,
"impressions": 2,
"responses": 1,
"correct": 1,
"unpaidResponses": 0,
"opened": 1,
"campaignCount": 1
}]
Pobierz ankietę
Pobranie pojedynczej ankiety. Otrzymasz całą ankietę, w tym informację o stronach, blokach, ... Aby wykonać zapytanie będziesz potrzebować id ankiety (survey-id). Możesz je znaleźć na stronie podglądu lub stronie projektu ankiety.
GET https://api.surveylab.com/api/v3/surveys/{survey-id}/
cURL
curl -i -X GET -H "Authorization:bearer YOUR_ACCESS_TOKEN" -H "Content-Type": "application/json" https://api.surveylab.com/api/v3/surveys/{survey-id}/
Przykład
GET https://api.surveylab.com/api/v3/surveys/21045/
Przykład wyniku zapytania
[{
"surveyId": 21045,
"userId": 127,
"modified": "2019-01-08 16:44:12",
"surveyThemeId": 90,
"languageId": null,
"name": "Was this article helpful",
"title": "Was this article helpful",
"questionNumbering": "survey",
"textDirection": "ltr",
"pageRotation": 0,
"blockRotation": 0,
"answerOneClick": false,
"blocksById": {
"25480": {
"blockId": 25480,
"surveyId": 21045,
"blockIsRotated": 0,
"blockNumber": 1,
"blockIdBySurvey": 1,
"blockName": "Block name",
"pagesOrder": {
"1": 85533
}
}
},
"pagesById": {
"85533": {
"surveyId": 21045,
"pageId": 85533,
"number": 1,
"pageIdBySurvey": 1,
"welcomePage": 0,
"title": "Untitled Page",
"description": null,
"titleVisible": 1,
"blockId": 25480,
"questionOffset": 0,
"questionsOrder": [
194238
],
"pageIsRotated": 0,
"questionsRotation": 0,
"randomQuestion": null
}
},
"questionsById": {
"194238": {
"questionId": 194238,
"pageId": 85533,
"type": "simple",
"params": {
"question": "Was this article helpful?",
"description": "",
"required": 0,
"comments": 0,
"exclusionQuestion": false,
"questionImgURL": "",
"maxNumberOfAnswers": 0,
"minNumberOfAnswers": 0,
"answers": [
"Yes",
"No"
],
"imageAnswer": [],
"open": "",
"multiple": 0,
"noneAbove": "",
"hideLableText": 0,
"points": 0,
"columnElements": 0,
"scoreArray": {
"0": "1",
"1": "-1",
"max": "1"
},
"presentationTiled": 1,
"presentation": "tiles-horizontal",
"random": 0,
"randomizeOptions": true
},
"questionIsRotated": 0,
"isRandomQuestion": 1,
"numbering": true,
"number": 1,
"questionIdBySurvey": 1,
"addedToBank": false,
"templateFile": "questions/simple.tpl",
"points": 0,
"opentext": "",
"open": 0
}
},
"public": 1,
"defaultTranslation": 1,
"blocksOrder": {
"1": 25480
}
}]
Pobierz pytania
Pobranie listy pytań dla wybranej ankiety. Otrzymasz tylko pytania (bez zebrancych odpowiedzi).
GET https://api.surveylab.com/api/v3/surveys/{survey-id}/questions/
cURL
curl -i -X GET -H "Authorization:bearer YOUR_ACCESS_TOKEN" -H "Content-Type": "application/json" https://api.surveylab.com/api/v3/surveys/{survey-id}/questions/
Przykład wyniku zapytania
[{
"questionId": 194238,
"number": 1,
"questionIdBySurvey": 1,
"type": "simple",
"questionParams": {
"question": "Was this article helpful?",
"description": "",
"translatable": {
"question": "Was this article helpful?",
"description": "",
"open": "",
"noneAbove": "",
"answers": [
"Yes",
"No"
]
},
"required": 0,
"comments": 0,
"exclusionQuestion": 0,
"questionImgURL": "",
"maxNumberOfAnswers": 0,
"minNumberOfAnswers": 0,
"answers": [
"Tak",
"Nie"
],
"imageAnswer": [],
"open": "",
"multiple": 0,
"noneAbove": "",
"hideLableText": 0,
"points": 0,
"columnElements": 0,
"scoreArray": {
"0": "1",
"1": "-1",
"max": "1"
},
"presentationTiled": 1,
"presentation": "tiles-horizontal",
"random": 0,
"randomizeOptions": true
}
}]
Pobierz odpowiedzi
Pobranie listy odpowiedzi, pierwsze 100 wpisów.
GET https://api.surveylab.com/api/v3/surveys/{survey-id}/responses/
cURL
curl -i -X GET -H "Authorization:bearer YOUR_ACCESS_TOKEN" -H "Content-Type": "application/json" https://api.surveylab.com/api/v3/surveys/{survey-id}/responses/
Przykład
GET https://api.surveylab.com/api/v3/surveys/21045/responses/
Przykład wyniku zapytania
[{
"responseId": 6923205,
"surveyId": 21045,
"iso3166": "PL",
"crk": null,
"promoCode": null,
"completed": 1,
"dateStart": "2019-01-03 13:26:34",
"dateCompleted": "2019-01-03 13:26:39",
"questionId": 194238,
"answer": [
0
],
"comment": "",
"score": null,
"matrixScore": null
},
{
"responseId": 6923207,
"surveyId": 21045,
"iso3166": "PL",
"crk": null,
"promoCode": null,
"completed": 1,
"dateStart": "2019-01-03 13:27:05",
"dateCompleted": "2019-01-03 13:27:08",
"questionId": 194238,
"answer": [
1
],
"comment": "",
"score": null,
"matrixScore": null
}]
Pobierz odpowiedzi (100)
Pobranie listy odpowiedzi, kolejne 100 wpisów. Zmień numer strony (np. /page/2/), aby pobrać kolejne 100 rekordów. Możesz ustawić sortowanie: asc (rosnąco) lub desc (malejąco).
GET https://api.surveylab.com/api/v3/surveys/{survey-id}/responses/page/2/
GET https://api.surveylab.com/api/v3/surveys/{survey-id}/responses/page/2/order/asc/
cURL
curl -i -X GET -H "Authorization:bearer YOUR_ACCESS_TOKEN" -H "Content-Type": "application/json" https://api.surveylab.com/api/v3/surveys/{survey-id}/responses/page/2/
curl -i -X GET -H "Authorization:bearer YOUR_ACCESS_TOKEN" -H "Content-Type": "application/json" https://api.surveylab.com/api/v3/surveys/{survey-id}/responses/page/1/order/asc/
Przykład
GET https://api.surveylab.com/api/v3/surveys/21045/responses/page/2/
GET https://api.surveylab.com/api/v3/surveys/21045/responses/page/2/order/asc/
Przykład wyniku zapytania
[{
"responseId": 6923209,
"surveyId": 21045,
"iso3166": "PL",
"crk": null,
"promoCode": null,
"completed": 1,
"dateStart": "2019-01-03 13:27:11",
"dateCompleted": "2019-01-03 13:27:13",
"questionId": 194238,
"answer": [
0
],
"comment": "",
"score": null,
"matrixScore": null
},
{
"responseId": 6923229,
"surveyId": 21045,
"iso3166": "PL",
"crk": null,
"promoCode": null,
"completed": 1,
"dateStart": "2019-01-03 13:32:29",
"dateCompleted": "2019-01-03 13:32:31",
"questionId": 194238,
"answer": [
0
],
"comment": "",
"score": 1,
"matrixScore": null
}]
Pobierz odpowiedź
Pobranie pojedynczej odpowiedzi dla wybranej ankiety. Możesz użyć zamiennie response-id lub crk.
GET https://api.surveylab.com/api/v3/surveys/{survey-id}/responses/{response-id}/
GET https://api.surveylab.com/api/v3/surveys/{survey-id}/responses/crk/{crk}/
cURL
curl -i -X GET -H "Authorization:bearer YOUR_ACCESS_TOKEN" -H "Content-Type": "application/json" https://api.surveylab.com/api/v3/surveys/{survey-id}/responses/{response-id}/
curl -i -X GET -H "Authorization:bearer YOUR_ACCESS_TOKEN" -H "Content-Type": "application/json" https://api.surveylab.com/api/v3/surveys/{survey-id}/responses/crk/{crk}/
Przykład
GET http://api.surveylab.com/api/v3/surveys/27162/responses/7423534/
GET http://api.surveylab.com/api/v3/surveys/27162/responses/crk/AGVIDd43/
Przykład wyniku zapytania
[{
}]
Pobierz miernik (Pojedyncza odpowiedź)
Pobierz wartość miernika dla pojedynczej odpowiedzi. Możesz użyć zmienne {survey-id} i {response-id}.
GET https://api.surveylab.com/api/v3/surveys/{survey-id}/responses/{response-id}/metrics/
cURL
curl -i -X GET -H "Authorization:bearer YOUR_ACCESS_TOKEN" -H "Content-Type": "application/json" https://api.surveylab.com/api/v3/surveys/{survey-id}/responses/{response-id}/metrics/
Przykład
GET https://api.surveylab.com/api/v3/surveys/52549/responses/18287824/metrics/
Przykład wyniku zapytania
[{
"12935": {
"metricId": 1267,
"surveyId": 52549,
"metricName": "CSAT",
"presentation": "points",
"maxValueIncludingEmptyAnswer": 0,
"testMode": 1,
"firstLevelThreshold": 12,
"secondLevelThreshold": null,
"created": "2022-10-26 12:30:00",
"score": {
"pointsSum": 24,
"maxPointsSum": 27,
"minPointsSum": 0,
"nps": false
}
}]
Pobierz miernik (Raport)
Pobierz wartość miernika dla raportu. Możesz użyć zmienne {survey-id} i {report-id}.
GET https://api.surveylab.com/api/v3/surveys/{survey-id}/reports/{report-id}/metrics/
cURL
curl -i -X GET -H "Authorization:bearer YOUR_ACCESS_TOKEN" -H "Content-Type": "application/json" https://api.surveylab.com/api/v3/surveys/{survey-id}/reports/{report-id}/metrics/
Przykład
GET https://api.surveylab.com/api/v3/surveys/52549/reports/177055/metrics/
Przykład wyniku zapytania
[{
"1267": {
"metricId": 1267,
"surveyId": 52549,
"metricName": "CSAT",
"presentation": "points",
"maxValueIncludingEmptyAnswer": 0,
"testMode": 0,
"firstLevelThreshold": null,
"secondLevelThreshold": null,
"created": "2022-10-26 12:30:00",
"score": "5.80",
"condition": "",
"maxPointsSum": 16,
"minPointSum": 0,
"responseSum": "15"
}]
Pobieranie metadanych, takich jak system operacyjny, przeglądarka, język czy rodzaj urządzenia.
cURL
curl -i -X GET -H "Authorization:bearer YOUR_ACCESS_TOKEN" -H "Content-Type": "application/json" https://api.surveylab.com/api/v3/surveys/{survey-id}/responses/{response-id}/metadata/
Przykład
GET https://api.surveylab.com/api/v3/surveys/27162/responses/7423534/metadata/
Przykład wyniku zapytania
[{
"responseId":8610691,
"ip":"127.0.0.1",
"referrer":null,
"iso3166":"PL",
"languageId":null,
"languageName":null,
"languageSymbol":null,
"deviceType":"desktop",
"deviceTypeName":"Desktop",
"os":"Ubuntu",
"browser":"Firefox 77.0"
}]
Pobierz listę raportów
Pobieranie listy raportów dla ankiety.
cURL
curl -i -X GET -H "Authorization:bearer YOUR_ACCESS_TOKEN" -H "Content-Type": "application/json" https://api.surveylab.com/api/v3/surveys/{survey-id}/reports/
Przykład
GET https://api.surveylab.com/api/v3/surveys/27162/resports/
Przykład wyniku zapytania
[{
"reportId": 4836,
"surveyId": 161,
"campaignId": null,
"reportType": "default",
"compareReportIdArray": null,
"publicName": null,
"dataPeriod": "week",
"mainReport": 1,
"campaignReport": 0,
"responseDateFirst": "2007-08-07 18:01:41",
"responseDateLast": "2020-06-09 12:13:02",
"created": "2011-04-15 07:44:34",
"checked": "2022-05-11 02:12:06",
"modified": "2022-05-11 02:12:17",
"responses": 32,
"currentlyProcessing": 0,
"currentlyExporting": 0
},
{
"reportId": 8039,
"surveyId": 161,
"campaignId": 114,
"reportType": "default",
"compareReportIdArray": null,
"publicName": null,
"dataPeriod": "week",
"mainReport": 0,
"campaignReport": 1,
"responseDateFirst": "2007-08-07 18:01:41",
"responseDateLast": "2009-03-11 20:42:09",
"created": "2011-04-15 07:44:50",
"checked": "2022-05-11 02:12:11",
"modified": "2022-05-11 02:12:27",
"responses": 30,
"currentlyProcessing": 0,
"currentlyExporting": 0
}]
Pobierz raport
Pobieranie wybranego raportu ankiety.
cURL
curl -i -X GET -H "Authorization:bearer YOUR_ACCESS_TOKEN" -H "Content-Type": "application/json" https://api.surveylab.com/api/v3/surveys/{survey-id}/reports/{report-id}/
Przykład
GET https://api.surveylab.com/api/v3/surveys/27162/reports/178267/
Przykład wyniku zapytania
[{
"surveyId": 53192,
"modified": "2022-12-15 14:47:56",
"title": "CSAT",
"name": "CSAT",
"displayBlocks": false,
"blocksOrder": [
59894
],
"blocksById": {
"59894": {
"blockId": 59894,
"blockIdBySurvey": 1,
"blockName": "Nazwa bloku",
"blockIsRandomizable": false,
"pagesOrder": [
240644
],
"surveyId": 53192,
"pagesRandomizationType": "none",
"pagesRandomizationSelections": []
}
},
"pagesById": {
"240644": {
"surveyId": 53192,
"blockId": 59894,
"description": null,
"pageId": 240644,
"pageIdBySurvey": 1,
"params": {
"title": "CSAT",
"questionsOrder": [
561138
]
},
"type": "default",
"hidedPage": false,
"started": null,
"finished": null
}
},
"questionsById": {
"561138": {
"hidedQuestion": false,
"comment": null,
"multimedia": null,
"imageAlt": null,
"pageId": 240644,
"params": {
"comments": false,
"description": "",
"descriptionType": "default",
"question": "Was this article helpful?",
"required": false,
"answer": [],
"columns": 0,
"multiple": false,
"multipleLimits": null,
"multipleLimitsEqual": null,
"multipleLimitsFrom": null,
"multipleLimitsTo": null,
"presentation": "vertical",
"hidedLabels": false,
"answers": [
{
"id": 0,
"label": "Yes",
"image": null,
"points": null,
"pointsNa": false,
"open": null,
"noneAbove": false
},
{
"id": 1,
"label": "No",
"image": null,
"points": null,
"pointsNa": false,
"open": null,
"noneAbove": false
}
],
"reportSettings": {
"showQuestionInPublic": true,
"showCommentInPublic": false,
"comment": ""
},
"reportData": {
"comments": {
"list": [],
"cloud": []
},
"results": {
"bar": {
"chart": [
"data",
1,
0
],
"chartXAxis": [
"x",
0,
1
],
"chartPercenages": [
"percentages",
100,
0
]
},
"otherData": []
}
}
},
"questionId": 561138,
"questionIdBySurvey": 1,
"type": "simple",
"responseCount": 1,
"questionScore": null,
"maxScore": null,
"reportSummary": {
"responses": 1,
"filtered": 0,
"score": null,
"scoreNumberOfItems": null,
"omitted": 0
},
"reportData": {
"closed": [
1,
0
],
"percentages": [
100,
0
],
"openCount": 0,
"noneAboveCount": 0
},
"score": null
}
},
"blocksIdByCode": {
"B1": 59894
},
"pagesIdByCode": {
"P1": 240644
},
"questionsIdByCode": {
"Q1": 561138
},
"responseCount": 1,
"reportId": 179334,
"mainReport": 1,
"responseDateLast": "2022-12-15 14:43:31",
"showPoints": true,
"showTrends": true,
"showCloudCharts": true,
"showMetrics": true,
"showBenchmarkMetrics": false,
"showQuestionTrends": false,
"showComments": true,
"showQuestionAnswerTags": false,
"showResponseStatuses": false,
"showResponseComments": false,
"dataPeriod": "day",
"reportName": "survr_MainReport",
"reportPublicName": null,
"campaignReport": false,
"reportType": "default"
}]
Skontaktuj się z nami
Stale udoskonalamy nasze oprogramowanie oraz API. Jeśli masz pytania lub potrzeby dotyczące API skontaktuj się z nami.
UWAGI. REST oznacza REpresentational State Transfer. API oznacza Application Programming Interface. JSON oznacza JavaScript Object Notation. JWT oznacza JSON Web Token.