Download Comments¶
On this page you will learn how to download the comments of your Kelvin components, for one component, for a group of components or for all of them.
Available Guides¶
- Find the Threads
- Get a Thread
- Download All Comments
- Download the Comments of One Component
- Download the Comments of a Group of Components
- Download Specific Comments
Overview¶
Threads and Comments¶
Comments in Kelvin live in Threads.
A Thread is the conversation of one Kelvin component, for example a Recommendation. The ID of the Thread is the KRN of that component, such as krn:recommendation:0198a7b0-0000-7000-8000-000000000001.
A Comment is a single message in that conversation. Every Comment has a thread_id that tells you which Thread, and so which component, it belongs to.
Recommendation krn:recommendation:0198a7b0-0000-7000-8000-000000000001
└── Thread id = krn:recommendation:0198a7b0-0000-7000-8000-000000000001
├── Comment thread_id = krn:recommendation:0198a7b0-0000-7000-8000-000000000001
├── Comment thread_id = krn:recommendation:0198a7b0-0000-7000-8000-000000000001
└── Comment thread_id = krn:recommendation:0198a7b0-0000-7000-8000-000000000001
This means that to download the comments of a component, you ask for the Comments of the Thread that has the KRN of that component.
The Endpoints¶
Three endpoints are used to export comments. You need the kelvin.permission.threads.read permission to use them.
| Endpoint | What it does |
|---|---|
GET /threads/list |
Lists the Threads. Use it to find which components have a conversation. |
GET /threads/{thread_id}/get |
Gets one Thread. |
POST /threads/comments/list |
Lists the Comments. This is the one that downloads the comments. |
Note
The two Threads endpoints return the Threads only, not the comments inside them. To download the comments you always use threads/comments/list.
Choose Which Comments You Want¶
You choose the comments by sending filters in the body of threads/comments/list. All the filters are optional.
| Filter | What it selects |
|---|---|
thread_ids |
The Comments of these Threads. You can give one KRN or many. |
ids |
These specific Comments, by Comment ID. |
| Both | Only the Comments that match ids and thread_ids together. |
None, an empty {} |
All the Comments. |
The filters are combined with AND. Inside one filter, a list of values means any of the values, so thread_ids with two KRNs returns the Comments of both Threads.
For example, this body asks for one specific Comment, but only if it belongs to that Recommendation.
| Comments list filters | |
|---|---|
Guides¶
Find the Threads¶
Start here if you want to see which components have a conversation.
| API cURL Example | |
|---|---|
To list only some Threads, add one ids parameter for each Thread, using the KRN of the component.
| API cURL Example | |
|---|---|
The response is a list of Threads. Each Thread has the fields in the Thread reference.
Get a Thread¶
Use this when you already know the component and want to see its Thread.
| API cURL Example | |
|---|---|
You will receive a response body with a status code of 200, indicating a successful operation. For example, the response body might look like this:
Download All Comments¶
Send an empty filter and you get every Comment.
| API cURL Example | |
|---|---|
The response is a list of Comments. Each Comment has the fields in the Comment reference.
The results are paginated, read Pagination to get all the pages.
Download the Comments of One Component¶
Use the KRN of the component in thread_ids. In this example we will get the Comments of one Recommendation.
| API cURL Example | |
|---|---|
You will receive a response body with a status code of 200, indicating a successful operation. For example, the response body might look like this:
The response will look like this;
Download the Comments of a Group of Components¶
Give more than one KRN in thread_ids. In this example we will get the Comments of two Recommendations at the same time.
The response is a list with the Comments of both components. Use the thread_id of each Comment to know which component it belongs to.
Download Specific Comments¶
Use ids to download Comments by their Comment ID. If you add thread_ids as well, you only get the Comments that match both.
Reference¶
Thread¶
| Field | Description |
|---|---|
| id | The Thread identifier. For Kelvin components this is the KRN of the component (e.g. krn:recommendation:<id>, krn:pcid:<change_id>, krn:datatag:<id>). |
| resources | Asset KRNs the Thread is about. |
| contexts | KRNs of any kind that give the Thread context. |
| created | UTC time when the Thread was created, formatted in RFC 3339. |
| created_by | User KRN that created the Thread. |
| updated | UTC time when the Thread or any of its Comments were last updated, formatted in RFC 3339. |
| updated_by | User KRN that last updated the Thread or one of its Comments. |
Comment¶
| Field | Description |
|---|---|
| id | The unique ID of the Comment. |
| thread_id | The Thread the Comment belongs to. For Kelvin components this is the KRN of the component. |
| text | The text of the Comment. |
| mentions | A list of user KRNs mentioned in the Comment. |
| metadata | Free-form JSON object stored with the Comment. |
| created | UTC time when the Comment was created, formatted in RFC 3339. |
| created_by | User KRN that authored the Comment. |
| updated | UTC time when the Comment was last updated, formatted in RFC 3339. |
| updated_by | User KRN that last updated the Comment. |
Pagination¶
threads/list and threads/comments/list return their results in pages. You can control this with these query parameters.
| Parameter | Description |
|---|---|
| pagination_type | cursor (default), limits or stream. cursor and limits return one page of results, stream returns all the results. |
| page_size | Number of results in each page, from 1 to 10000. The default is 20. |
| page | The page number you want. Used only with limits. |
| next | Bookmark of where to start the next page. Used only with cursor. |
| previous | Bookmark of where to end the previous page. Used only with cursor. |
| direction | asc (default) or desc. The sorting order of sort_by. |
| sort_by | Sort by id, created, created_by, updated or updated_by. |
In the Kelvin API Client (Python) you can pass the same options as arguments, for example page_size=100.