Go to

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.
429 Zbyt wiele zapytań.
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 https://api.surveylab.com/api/v3/surveys/27162/responses/7423534/
GET https://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”
}]

Pobierz metadane

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}

Powiązane strony