Manage custom tags on your documents by API
Field to use as parameter in the API
You can update the tags on a document which is indexed in your project by using the modify document API. More information can be found here: Modifying documents with the Talkwalker API
The field tags_customer
can be used to update the tags on a document. As it accept arrays, it supports operators +
and -
as prefix :
+tags_customer
to add tags to the existing tags on the document.-tags_customer
to remove specific tags from the document.tags_customer
to reset the tags on the document.
The value to use is the label of the tag, not their ID.
Add a tag on a document
To add a tags on a document, we can use following request:
curl -X POST 'https://api.talkwalker.com/api/v2/docs/p/<project_id>/update?access_token=<access_token>' -H 'Content-Type: application/json' --data-raw '{
"url": "<document_url>",
"+tags_customer": [ “<tag_label>”, “<tag_label>”, ...]
}'
If the tag does not exist in the project, it will be automatically created in the project configuration.
In our sample, we will add the tag “Pascal” on the following document with URL: http://www.youtube.com/watch?v=a3g7IROzfa0
Result in Talkwalker platform:
Create a tag in the project’s configuration
When you add a tag on a document, if the tag does not exist in the project, it will be automatically created in the project configuration.
It's impossible to update/delete a tag from the project's configuration by API. This must be done from the platform.
In this sample, We will add the tag “Pascal2” on the document with URL: http://www.youtube.com/watch?v=a3g7IROzfa0. This tag is not part of the project’s configuration.
curl -X POST 'https://api.talkwalker.com/api/v2/docs/p/<project_id>/update?access_token=<access_token>' -H 'Content-Type: application/json' --data-raw '{
"url": "http://www.youtube.com/watch?v=a3g7IROzfa0",
"+tags_customer": [ "Pascal2" ]
}'
Result in Talkwalker platform:
And in the project settings:
Remove a tag on a document
To remove tags on a document, we can use following request:
curl -X POST 'https://api.talkwalker.com/api/v2/docs/p/<project_id>/update?access_token=<access_token>' -H 'Content-Type: application/json' --data-raw '{
"url": "<document_url>",
"-tags_customer": [ “<tag_label>”, “<tag_label>”, ...]
}'
In our sample we will remove the tag “Pascal” from the document with the URL: http://www.youtube.com/watch?v=a3g7IROzfa0.
Result in talkwalker platform:
Reset tags on a document
To reset and change all tags on a document, we can use following request:
curl -X POST 'https://api.talkwalker.com/api/v2/docs/p/<project_id>/update?access_token=<access_token>' -H 'Content-Type: application/json' --data-raw '{
"url": "<document_url>",
"tags_customer": [ “<tag_label>”, “<tag_label>”, ...]
}'
It will remove all existing tags from a document and replace them with the new list of tags.
In our sample, we will change the tag “Pascal2” from the document with URL: http://www.youtube.com/watch?v=a3g7IROzfa0. It will be replaced by the tags “Employee type/Technical” and “Pascal”:
Result in talkwalker platform:
Remove all tags from a document
To remove all tags from a document, we can use following request with an empty array:
curl -X POST 'https://api.talkwalker.com/api/v2/docs/p/<project_id>/update?access_token=<access_token>' -H 'Content-Type: application/json' --data-raw '{
"url": "<document_url>",
"tags_customer": [ ]
}'
It will remove all existing tags from a document.
In our sample, we will remove all tags from the document with URL: http://www.youtube.com/watch?v=a3g7IROzfa0.
Result in Talkwalker platform: