A small example

This example assumes you already generated a token and created an organization. We'll use:

  • hFCSR1sPJPFW6zH.0ygrZcFrWNnJX04.CkBXBFVevJx2baZ as a token
  • aaa888222aaa3330000ffff as an organization ID
POST /api/v2/organizations/aaa888222aaa3330000ffff/datasets
Authorization: Bearer hFCSR1sPJPFW6zH.0ygrZcFrWNnJX04.CkBXBFVevJx2baZ
Content-Type: application/json
Accept: application/json

{
    "name": "Survey results for Fictional Hotel",
    "description": "",
    "fields": [{
        "dataType": "Number",
        "analyze": false,
        "name": "survey_id",
        "isPrimaryKey": true
    }, {
        "dataType": "Date",
        "analyze": false,
        "name": "survey_date",
        "dateFormat": "MM-DD-YYYY"
    }, {
        "dataType": "String",
        "analyze": true,
        "name": "Did you enjoy your stay?",
        "mappingName": "1343"
    }, {
        "dataType": "String",
        "analyze": true,
        "name": "What was your favorite part?",
        "mappingName": "1292"
    }, {
        "dataType": "String",
        "analyze": false,
        "name": "city",
        "mappingName": "17"
    }, {
        "dataType": "URL",
        "analyze": false,
        "name": "survey_url"
    }]
}

This will create a dataset with 5 fields. Two of them contain survey responses to analyze. The response to this request is the dataset ID 5703d9432327d444004e7c3d.

We can then populate the dataset:

POST /api/v2/datasets/5703d9432327d444004e7c3d/records
Authorization: Bearer hFCSR1sPJPFW6zH.0ygrZcFrWNnJX04.CkBXBFVevJx2baZ
Content-Type: application/json
Accept: application/json

{
    "records": [{
        "1343": "Overall yes, although the bathroom was a bit unclean.",
        "1292": "My wife and I enjoyed watching the sunset from our room.",
        "survey_date": "10-06-2012",
        "survey_url": {
            "target": "http://mysite.com/4055629"
            "label": "survey #4055629"
        },
        "survey_id": 4055629,
        "city": "Montreal"
    }, {
        "1343": "Not at all, I wish I could get my money back.",
        "1292": "Everything was terrible.",
        "survey_date": "05-08-2012",
        "survey_url": {
            "target": "http://mysite.com/41133812"
            "label": "survey #41133812"
        },
        "survey_id": 41133812,
        "city": "Paris"
    }],
    "hasMore": false
}

Here we add two records to the dataset. Afterwards, we can get analytics for the second one:

GET /api/v2/datasets/5703d9432327d444004e7c3d/analytics?recordId=41133812&fields=[city]
Authorization: Bearer hFCSR1sPJPFW6zH.0ygrZcFrWNnJX04.CkBXBFVevJx2baZ
Accept: application/json

and get this:

{
    "record": {
        "city": "Paris"
    },
    "results": [{
        "fieldName": "Did you enjoy your stay?",
        "fieldMappingName": "1343",
        "sentiment": "negative"
    }, {
        "fieldName": "What was your favorite part?",
        "fieldMappingName": "1292",
        "sentiment": "negative"
    }]
}

results matching ""

    No results matching ""