Search search
Help sections
FAQ

REST API

MySurveyLab allows you to access your data with the REST API interface. Access to API is available with a secure connection (SSL / HTTPS) and require a token. Data are available in JSON format. User authentication is done with JWT.

List of available requests

  • get token
  • get survey list
  • get survey
  • get survey questions
  • get survey responses


Status codes

The statuses are returned using the standard HTTP error code syntax.

Code Description
200 The request was successful.
400 The request was incorrect. Invalid API token.
401 Unauthorized. You attempt to authenticate with an invalid username or API key.
404 Not Found. The resource doesn’t exist.
500 Internal Server Error. Please try again or contact our support.
 

Get token

Obtaining an access token for communication. The token is valid for 30 days.

POST https://api.mysurveylab.com/oauth/token/

cURL
curl -i -X POST https://api.mysurveylab.com/oauth/token/ -d "clientSecret=YOUR_CLIENT_SECRET &clientId=YOUR_CLIENT_ID

Result example

Access token

NOTE. In order to use the API, you will need clientId and clientSecret. This information is provided on request. To get it please contact us.

 

Get survey list

Obtaining the list of surveys. You will get a list of all surveys on your account.

GET https://api.mysurveylab.com/api/v2/surveys/

cURL
curl -i -X GET -H "Authorization:bearer YOUR_ACCESS_TOKEN" -H "Content-Type": "application/json" https://api.mysurveylab.com/api/v2/surveys/

Result example

{
        "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
    },


Get survey

Obtaining single survey. You will get the whole survey, including information about pages, blocks, etc. To send this request you will need to know survey id. You can find it on the survey preview or on the survey desing page. 

GET https://api.mysurveylab.com/api/v2/surveys/:id/

cURL
curl -i -X GET -H "Authorization:bearer YOUR_ACCESS_TOKEN" -H "Content-Type": "application/json" https://api.mysurveylab.com/api/v2/surveys/:id/

Example
GET https://api.mysurveylab.com/api/v2/surveys/21045/

Result example

{
    "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
    }
}
 


Get survey questions

Obtaining survey questions. You will get survey questions only. 

GET https://api.mysurveylab.com/api/v2/surveys/:id/questions/

cURL
curl -i -X GET -H "Authorization:bearer YOUR_ACCESS_TOKEN" -H "Content-Type": "application/json" https://api.mysurveylab.com/api/v2/surveys/:id/questions/

Result example

{
        "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
        }
    }
 


Get survey responses

Obtaining survey responses, first 100 records.

GET https://api.mysurveylab.com/api/v2/surveys/:id/responses

cURL
curl -i -X GET -H "Authorization:bearer YOUR_ACCESS_TOKEN" -H "Content-Type": "application/json" https://api.mysurveylab.com/api/v2/surveys/:id/responses

Example
GET https://api.mysurveylab.com/api/v2/surveys/21045/responses

Result example 

{
        "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
    },
 


Get survey repsonses

Obtaining survey responses, second 100 records. Change page number (eg. /page/3/) to get next 100 respondents.

GET https://api.mysurveylab.com/api/v2/surveys/:id/page/2/responses

cURL
curl -i -X GET -H "Authorization:bearer YOUR_ACCESS_TOKEN" -H "Content-Type": "application/json" https://api.mysurveylab.com/api/v2/surveys/:id/page/2/responses

Example 
GET https://api.mysurveylab.com/api/v2/surveys/21045/page/2/responses

Result example 

{
        "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
    },
 

Contact us

We are constantly improving our survey software and API. If you have any questions or needs regarding the API please contact us.

NOTE. REST is an acronym for REpresentational State Transfer. API is an acronym for Application Programming Interface. JSON is an acronym for JavaScript Object Notation. JWT is an acronym for JSON Web Token.

* Functionality is available for Enterprise plan.
 

Related pages