API EndpointsCommentsFetch Comments

Fetch Comments

Endpoint

URL: https://api.replyke.com/:projectId/comments/

Method: GET

Authentication Required: No


Description

This endpoint allows users to fetch multiple comments based on various filters such as entity, user, or parent comment. The comments can be sorted by different criteria and paginated for efficient retrieval.

At least one of entityId, userId, or parentId must be provided in the request.


Request

Query Parameters

ParameterTypeRequiredDescription
entityIdstringConditionalFetch comments for a specific entity. Required if userId and parentId are not provided.
userIdstringConditionalFetch comments made by a specific user. Required if entityId and parentId are not provided.
parentIdstringConditionalFetch replies to a specific parent comment. Required if entityId and userId are not provided.
sortBystringNoSorting criteria (new, old, top, controversial). Defaults to new.
pagenumberNoPage number for pagination (default: 1).
limitnumberNoNumber of comments per page (default: 10).
includeEntitybooleanNoWhether to include entity details in the response (default: false).

Response

Success Response (200 OK)

[
  {
    "id": "<COMMENT_ID>",
    "projectId": "<PROJECT_ID>",
    "userId": "<USER_ID>",
    "entityId": "<ENTITY_ID>",
    "parentId": "<PARENT_ID>",
    "content": "<COMMENT_CONTENT>",
    "gif": {
      "id": "<GIF_ID>",
      "gifUrl": "<GIF_URL>",
      "gifPreviewUrl": "<GIF_PREVIEW_URL>",
      "altText": "<ALT_TEXT>",
      "url": "<URL>",
      "aspectRatio": "<ASPECT_RATIO>"
    },
    "mentions": ["<UPDATED_MENTIONS_ARRAY>"],
    "upvotes": ["<UPDATED_UPVOTES_ARRAY>"],
    "downvotes": ["<UPDATED_DOWNVOTES_ARRAY>"]
    "createdAt": "<TIMESTAMP>",
    "updatedAt": "<TIMESTAMP>",
    "deletedAt": null
  }
]

Error Responses

Invalid Request Data (400 Bad Request)

{
  "error": "Invalid request data"
}

Reason: The request did not include at least one of entityId, userId, or parentId.

Server Error (500 Internal Server Error)

{
  "error": "Server error"
}

Reason: An unexpected error occurred while processing the request.


Notes

  • The response includes an array of comments matching the specified filters.
  • At least one of entityId, userId, or parentId must be provided; otherwise, the request will be rejected.
  • Sorting options:
    • new: Sorts by newest first (default).
    • old: Sorts by oldest first.
    • top: Sorts by highest net upvotes (upvotes - downvotes).
    • controversial: Sorts by the most evenly split upvotes and downvotes.
  • Pagination ensures efficient data retrieval, with page controlling the offset and limit controlling the number of comments returned.
  • If includeEntity=true, the response will also include entity details associated with each comment.