diff --git a/README.md b/README.md index 7e33841..f3d870a 100644 --- a/README.md +++ b/README.md @@ -2719,6 +2719,56 @@ Example of a comment object } ``` +### Get Project Comments + +Get comment threads of a project. Returns up to 1000 comment threads per request. Use `offset` for pagination. + +```python +comment_threads = client.get_project_comments(project="YOUR_PROJECT_SLUG") +``` + +#### Parameters + +| Name | Type | Required | Description | +|------|------|----------|-------------| +| project | str | Yes | Project slug | +| status | str | No | Filter by task status | +| external_status | str | No | Filter by task external status | +| tags | list | No | Filter by task tags | +| issue_category_id | str | No | Filter by issue category ID | +| offset | int | No | Offset for pagination | +| limit | int | No | Number of comment threads to retrieve (default: 100, max: 1000) | + +#### Response + +Example of a comment thread object + +```python +{ + "id": "YOUR_THREAD_ID", + "text": "comment text", + "comment": { + "id": "YOUR_COMMENT_ID", + "taskId": "YOUR_TASK_ID", + "contentId": "YOUR_CONTENT_ID", + "type": "text", + "isResolved": False, + "points": [185.98, 86.55], + "scale": 0, + "frame": 0, + "status": "todo", + "priority": 0, + "taskAnnotationId": None, + "issueCategoryId": None, + "color": None, + "createdAt": "2026-03-03T03:51:55.240Z", + "updatedAt": "2026-03-03T03:51:55.240Z", + }, + "createdAt": "2026-03-03T03:51:55.247Z", + "updatedAt": "2026-03-03T03:51:55.247Z", +} +``` + ## Project ### Create Project diff --git a/examples/get_project_comments.py b/examples/get_project_comments.py new file mode 100644 index 0000000..f03a61e --- /dev/null +++ b/examples/get_project_comments.py @@ -0,0 +1,8 @@ +from pprint import pprint + +import fastlabel + +client = fastlabel.Client() + +comment_threads = client.get_project_comments(project="YOUR_PROJECT_SLUG") +pprint(comment_threads) diff --git a/fastlabel/__init__.py b/fastlabel/__init__.py index 1d702ed..5b79c1f 100644 --- a/fastlabel/__init__.py +++ b/fastlabel/__init__.py @@ -5248,12 +5248,40 @@ def get_task_comments( "Limit must be less than or equal to 1000.", 422 ) endpoint = "comments" + params = {"project": project, "taskId": task_id} + if offset is not None: + params["offset"] = offset + if limit is not None: + params["limit"] = limit + return self.api.get_request(endpoint, params=params) + + def get_project_comments( + self, + project: str, + status: str = None, + external_status: str = None, + tags: list = None, + issue_category_id: str = None, + offset: int = None, + limit: int = 100, + ) -> list: + if limit > 1000: + raise FastLabelInvalidException( + "Limit must be less than or equal to 1000.", 422 + ) + endpoint = "comments/threads" params = {"project": project} - if task_id: - params["taskId"] = task_id - if offset: + if status: + params["taskStatus"] = status + if external_status: + params["taskExternalStatus"] = external_status + if tags: + params["taskTags"] = tags + if issue_category_id: + params["issueCategoryId"] = issue_category_id + if offset is not None: params["offset"] = offset - if limit: + if limit is not None: params["limit"] = limit return self.api.get_request(endpoint, params=params)