Skip to main content

API calls to upload a review

Overview

It used the same principles as the upload of articles, except that the dataset ID must be provided in the API endpoint.

Command
POST https://api.talkwalker.com/api/v2/docs/p/<project_id>/d/<dataset_id>/<operation>?access_token=<access_token>

All details on how to upload articles: How to upload a new document via API

How to retrieve dataset IDs

You can use the API endpoint:

Command
https://api.talkwalker.com/api/v2/talkwalker/p/<project_id>/resources?access_token=<access_token>&type=dataset

It will return all datasets defined in your project:

Sample
{
"status_code": "0",
"status_message": "OK",
"request": "GET /api/v2/talkwalker/p/<project_id>/resources?access_token=<access_tiken>&type=dataset",
"result_resources": {
"projects": [
{
"id": "<project_id>",
"title": "Pascal's CI Project",
"datasets": [
{
"id": "ac5bc7fd-abcd-4e34-1234-d546jbb33a2fe",
"title": "QUESTIONS"
},
{
"id": "ac5bc7fd-7a5e-4e34-800f-d546jbb33a2fe",
"title": "reviews"
}
]
}
]
},
"request_id": "#rynjbmoldav8#"
}

Sample to upload a review

Command
POST https://api.talkwalker.com/api/v2/docs/p/<project_id>/d/<dataset_id>/upsert?access_token=<access_token>&return_entry=show&annotate=sentiment
Request
{
"url": "https://test_ci_pcl.lu/datashake/2",
"parent_url": "https://test_ci_pcl.lu/datashake/2",
"title": "Custom labels",
"content": "I'm trying to add a label as it's not possible through the UI... :(",
"published": "1687818210000",
"extra_source_attributes": {
"geo": "lu"
},
"rating": 0,
"extra_author_attributes": {
"name": "Shy",
"gender": "FEMALE"
},
"custom": {
"helpful": 2,
"positive_votes": 1
},
"label": [
{
"type": "product_type",
"id": "API"
}
]
}
note

Custom fields need to be manually created first.

Sample to upload a batch of reviews

Command
POST https://api.talkwalker.com/api/v2/docs/p/<project_id>/d/<dataset_id>?access_token=<access_token>&return_entry=show&annotate=sentiment
Request
[
{
"upsert": {
"url": "https://test_ci_pcl.lu/1063730/",
"title": "Test upload in a dataset by API",
"content": "Is the URL sufficient to upload in a dataset ?",
"published": "1646821290000",
"rating": 3,
"parent_url":"https://test_ci_pcl.lu/1063730/"
}
},
{
"upsert": {
"url": "https://test_ci_pcl.lu/1063730/222",
"title": "Test upload in a dataset by API - 2",
"content": "test with custom metrics",
"published": "1646824890000",
"rating": 10,
"custom": {
"helpful": 1
},
"parent_url": "https://test_ci_pcl.lu/1063730/222"
}
}
]