GET /api/v1/comments
List comments


GET /api/v1/comments/:id
Show a comment

Examples

GET /api/v2/comments/223
200
{
  "data": {
    "id": "223",
    "type": "comments",
    "links": {
      "self": "http://test.host/api/v2/comments/223"
    },
    "attributes": {
      "body": "comment text",
      "created-at": "2017-08-29T10:50:55.016+08:00",
      "body-updated-at": "2017-08-29T10:50:55.015+08:00",
      "updated-at": "2017-08-29T10:50:55.016+08:00",
      "anonymize": false,
      "likes-count": 0,
      "is-liked": false,
      "revisions-count": 0,
      "has-parent": false
    },
    "relationships": {
      "attachment": {
        "links": {
          "self": "http://test.host/api/v2/comments/223/relationships/attachment",
          "related": "http://test.host/api/v2/comments/223/attachment"
        }
      },
      "commentable": {
        "links": {
          "self": "http://test.host/api/v2/comments/223/relationships/commentable",
          "related": "http://test.host/api/v2/comments/223/commentable"
        }
      },
      "commenter": {
        "links": {
          "self": "http://test.host/api/v2/comments/223/relationships/commenter",
          "related": "http://test.host/api/v2/comments/223/commenter"
        }
      },
      "parent": {
        "links": {
          "self": "http://test.host/api/v2/comments/223/relationships/parent",
          "related": "http://test.host/api/v2/comments/223/parent"
        }
      },
      "children": {
        "links": {
          "self": "http://test.host/api/v2/comments/223/relationships/children",
          "related": "http://test.host/api/v2/comments/223/children"
        }
      },
      "commentable-insights": {
        "links": {
          "self": "http://test.host/api/v2/comments/223/relationships/commentable-insights",
          "related": "http://test.host/api/v2/comments/223/commentable-insights"
        }
      },
      "commentable-entities": {
        "links": {
          "self": "http://test.host/api/v2/comments/223/relationships/commentable-entities",
          "related": "http://test.host/api/v2/comments/223/commentable-entities"
        }
      },
      "comment-likes": {
        "links": {
          "self": "http://test.host/api/v2/comments/223/relationships/comment-likes",
          "related": "http://test.host/api/v2/comments/223/comment-likes"
        }
      },
      "comment-revisions": {
        "links": {
          "self": "http://test.host/api/v2/comments/223/relationships/comment-revisions",
          "related": "http://test.host/api/v2/comments/223/comment-revisions"
        }
      }
    }
  }
}

Params

Param name Description
id
required

Comment ID

Validations:

  • Must be an identifier, string from 1 to 128 characters containing only alphanumeric characters, space, underscore(_), hyphen(-) with no leading or trailing space.


POST /api/v1/comments
Post a comment on any commentable

Examples

POST /api/v2/comments
{
  "data": {
    "type": "comments",
    "attributes": {
      "body": "comment text",
      "created-at": null,
      "body-updated-at": null,
      "updated-at": null,
      "anonymize": false,
      "likes-count": "0",
      "is-liked": false,
      "revisions-count": "0",
      "has-parent": false
    },
    "relationships": {
      "commentable": {
        "data": {
          "type": "entities",
          "id": "207"
        }
      }
    }
  }
}
201
{
  "data": {
    "id": "66",
    "type": "comments",
    "links": {
      "self": "http://test.host/api/v2/comments/66"
    },
    "attributes": {
      "body": "comment text",
      "created-at": "2017-08-29T10:47:39.559+08:00",
      "body-updated-at": "2017-08-29T10:47:39.558+08:00",
      "updated-at": "2017-08-29T10:47:39.559+08:00",
      "anonymize": false,
      "likes-count": 0,
      "is-liked": false,
      "revisions-count": 0,
      "has-parent": false
    },
    "relationships": {
      "attachment": {
        "links": {
          "self": "http://test.host/api/v2/comments/66/relationships/attachment",
          "related": "http://test.host/api/v2/comments/66/attachment"
        }
      },
      "commentable": {
        "links": {
          "self": "http://test.host/api/v2/comments/66/relationships/commentable",
          "related": "http://test.host/api/v2/comments/66/commentable"
        }
      },
      "commenter": {
        "links": {
          "self": "http://test.host/api/v2/comments/66/relationships/commenter",
          "related": "http://test.host/api/v2/comments/66/commenter"
        }
      },
      "parent": {
        "links": {
          "self": "http://test.host/api/v2/comments/66/relationships/parent",
          "related": "http://test.host/api/v2/comments/66/parent"
        }
      },
      "children": {
        "links": {
          "self": "http://test.host/api/v2/comments/66/relationships/children",
          "related": "http://test.host/api/v2/comments/66/children"
        }
      },
      "commentable-insights": {
        "links": {
          "self": "http://test.host/api/v2/comments/66/relationships/commentable-insights",
          "related": "http://test.host/api/v2/comments/66/commentable-insights"
        }
      },
      "commentable-entities": {
        "links": {
          "self": "http://test.host/api/v2/comments/66/relationships/commentable-entities",
          "related": "http://test.host/api/v2/comments/66/commentable-entities"
        }
      },
      "comment-likes": {
        "links": {
          "self": "http://test.host/api/v2/comments/66/relationships/comment-likes",
          "related": "http://test.host/api/v2/comments/66/comment-likes"
        }
      },
      "comment-revisions": {
        "links": {
          "self": "http://test.host/api/v2/comments/66/relationships/comment-revisions",
          "related": "http://test.host/api/v2/comments/66/comment-revisions"
        }
      }
    }
  }
}

Params

Param name Description
data
required

Comment information

Validations:

  • Must be a Hash

data[type]
required

Validations:

data[attributes]
required

Validations:

  • Must be a Hash

data[attributes][body]
required

Comment's body

Validations:

  • Must be a String

data[relationships]
required

Validations:

  • Must be a Hash

data[relationships][commentable]
required

Validations:

  • Must be a Hash

data[relationships][commentable][data]
required

Validations:

  • Must be a Hash

data[relationships][commentable][data][type]
required

Content being commented on, which is `insights`

Validations:

  • Must be a String

data[relationships][commentable][data][id]
required

Insight ID

Validations:

  • Must be an identifier, string from 1 to 128 characters containing only alphanumeric characters, space, underscore(_), hyphen(-) with no leading or trailing space.

data[relationships][commenter]
required

Validations:

  • Must be a Hash

data[relationships][commenter][data]
required

Validations:

  • Must be an Array of nested elements

data[relationships][commenter][data][type]
required

Account type, which is `accounts`

Validations:

  • Must be a String

data[relationships][commenter][data][id]
required

Account ID who is commenting

Validations:

  • Must be an identifier, string from 1 to 128 characters containing only alphanumeric characters, space, underscore(_), hyphen(-) with no leading or trailing space.

data[relationships][parent]
optional , nil allowed

Validations:

  • Must be a Hash

data[relationships][parent][data]
required

Validations:

  • Must be an Array of nested elements

data[relationships][parent][data][type]
required

The parent comment, which is `comments`

Validations:

  • Must be a String

data[relationships][parent][data][id]
required

Comment ID of comment being replied to

Validations:

  • Must be an identifier, string from 1 to 128 characters containing only alphanumeric characters, space, underscore(_), hyphen(-) with no leading or trailing space.


DELETE /api/v1/comments/:id
Delete own comment on a commentable

Examples

DELETE /api/v2/comments/36
204
{}

Params

Param name Description
id
required

Comment ID

Validations:

  • Must be an identifier, string from 1 to 128 characters containing only alphanumeric characters, space, underscore(_), hyphen(-) with no leading or trailing space.


PATCH /api/v2/comments/:id
Update comment body

Examples

PATCH /api/v2/comments/49
{
  "data": {
    "id": "49",
    "type": "comments",
    "attributes": {
      "body": "new comment body"
    }
  }
}
200
{
  "data": {
    "id": "49",
    "type": "comments",
    "links": {
      "self": "http://test.host/api/v2/comments/49"
    },
    "attributes": {
      "body": "new comment body",
      "created-at": "2017-08-29T10:46:52.081+08:00",
      "body-updated-at": "2017-08-29T10:46:52.524+08:00",
      "updated-at": "2017-08-29T10:46:52.525+08:00",
      "anonymize": false,
      "likes-count": 0,
      "is-liked": false,
      "revisions-count": 1,
      "has-parent": false
    },
    "relationships": {
      "attachment": {
        "links": {
          "self": "http://test.host/api/v2/comments/49/relationships/attachment",
          "related": "http://test.host/api/v2/comments/49/attachment"
        }
      },
      "commentable": {
        "links": {
          "self": "http://test.host/api/v2/comments/49/relationships/commentable",
          "related": "http://test.host/api/v2/comments/49/commentable"
        }
      },
      "commenter": {
        "links": {
          "self": "http://test.host/api/v2/comments/49/relationships/commenter",
          "related": "http://test.host/api/v2/comments/49/commenter"
        }
      },
      "parent": {
        "links": {
          "self": "http://test.host/api/v2/comments/49/relationships/parent",
          "related": "http://test.host/api/v2/comments/49/parent"
        }
      },
      "children": {
        "links": {
          "self": "http://test.host/api/v2/comments/49/relationships/children",
          "related": "http://test.host/api/v2/comments/49/children"
        }
      },
      "commentable-insights": {
        "links": {
          "self": "http://test.host/api/v2/comments/49/relationships/commentable-insights",
          "related": "http://test.host/api/v2/comments/49/commentable-insights"
        }
      },
      "commentable-entities": {
        "links": {
          "self": "http://test.host/api/v2/comments/49/relationships/commentable-entities",
          "related": "http://test.host/api/v2/comments/49/commentable-entities"
        }
      },
      "comment-likes": {
        "links": {
          "self": "http://test.host/api/v2/comments/49/relationships/comment-likes",
          "related": "http://test.host/api/v2/comments/49/comment-likes"
        }
      },
      "comment-revisions": {
        "links": {
          "self": "http://test.host/api/v2/comments/49/relationships/comment-revisions",
          "related": "http://test.host/api/v2/comments/49/comment-revisions"
        }
      }
    }
  }
}

Params

Param name Description
id
required

Comment ID

Validations:

  • Must be an identifier, string from 1 to 128 characters containing only alphanumeric characters, space, underscore(_), hyphen(-) with no leading or trailing space.

data
required

Comment information

Validations:

  • Must be a Hash

data[type]
optional

Validations:

data[attributes]
optional

Validations:

  • Must be a Hash

data[attributes][body]
optional

Comment's body

Validations:

  • Must be a String


PATCH /api/v2/comments/:id/remove
Soft-Remove the comment


PATCH /api/v2/comments/:id/like
Like a comment

Examples

PATCH /api/v2/comments/26/like
{}
200
{
  "data": {
    "id": "26",
    "type": "comments",
    "links": {
      "self": "/api/v2/comments/26"
    },
    "attributes": {
      "body": "comment text",
      "created-at": "2017-08-29T10:45:59.820+08:00",
      "body-updated-at": "2017-08-29T10:45:59.817+08:00",
      "updated-at": "2017-08-29T10:45:59.820+08:00",
      "anonymize": false,
      "likes-count": 1,
      "is-liked": true,
      "revisions-count": 0,
      "has-parent": false
    },
    "relationships": {
      "attachment": {
        "links": {
          "self": "/api/v2/comments/26/relationships/attachment",
          "related": "/api/v2/comments/26/attachment"
        }
      },
      "commentable": {
        "links": {
          "self": "/api/v2/comments/26/relationships/commentable",
          "related": "/api/v2/comments/26/commentable"
        }
      },
      "commenter": {
        "links": {
          "self": "/api/v2/comments/26/relationships/commenter",
          "related": "/api/v2/comments/26/commenter"
        }
      },
      "parent": {
        "links": {
          "self": "/api/v2/comments/26/relationships/parent",
          "related": "/api/v2/comments/26/parent"
        }
      },
      "children": {
        "links": {
          "self": "/api/v2/comments/26/relationships/children",
          "related": "/api/v2/comments/26/children"
        }
      },
      "commentable-insights": {
        "links": {
          "self": "/api/v2/comments/26/relationships/commentable-insights",
          "related": "/api/v2/comments/26/commentable-insights"
        }
      },
      "commentable-entities": {
        "links": {
          "self": "/api/v2/comments/26/relationships/commentable-entities",
          "related": "/api/v2/comments/26/commentable-entities"
        }
      },
      "comment-likes": {
        "links": {
          "self": "/api/v2/comments/26/relationships/comment-likes",
          "related": "/api/v2/comments/26/comment-likes"
        }
      },
      "comment-revisions": {
        "links": {
          "self": "/api/v2/comments/26/relationships/comment-revisions",
          "related": "/api/v2/comments/26/comment-revisions"
        }
      }
    }
  }
}

PATCH /api/v2/comments/:id/unlike
Remove like from comment

Examples

PATCH /api/v2/comments/32/unlike
{}
200
{
  "data": {
    "id": "32",
    "type": "comments",
    "links": {
      "self": "/api/v2/comments/32"
    },
    "attributes": {
      "body": "comment text",
      "created-at": "2017-08-29T10:46:13.801+08:00",
      "body-updated-at": "2017-08-29T10:46:13.800+08:00",
      "updated-at": "2017-08-29T10:46:13.801+08:00",
      "anonymize": false,
      "likes-count": 0,
      "is-liked": false,
      "revisions-count": 0,
      "has-parent": false
    },
    "relationships": {
      "attachment": {
        "links": {
          "self": "/api/v2/comments/32/relationships/attachment",
          "related": "/api/v2/comments/32/attachment"
        }
      },
      "commentable": {
        "links": {
          "self": "/api/v2/comments/32/relationships/commentable",
          "related": "/api/v2/comments/32/commentable"
        }
      },
      "commenter": {
        "links": {
          "self": "/api/v2/comments/32/relationships/commenter",
          "related": "/api/v2/comments/32/commenter"
        }
      },
      "parent": {
        "links": {
          "self": "/api/v2/comments/32/relationships/parent",
          "related": "/api/v2/comments/32/parent"
        }
      },
      "children": {
        "links": {
          "self": "/api/v2/comments/32/relationships/children",
          "related": "/api/v2/comments/32/children"
        }
      },
      "commentable-insights": {
        "links": {
          "self": "/api/v2/comments/32/relationships/commentable-insights",
          "related": "/api/v2/comments/32/commentable-insights"
        }
      },
      "commentable-entities": {
        "links": {
          "self": "/api/v2/comments/32/relationships/commentable-entities",
          "related": "/api/v2/comments/32/commentable-entities"
        }
      },
      "comment-likes": {
        "links": {
          "self": "/api/v2/comments/32/relationships/comment-likes",
          "related": "/api/v2/comments/32/comment-likes"
        }
      },
      "comment-revisions": {
        "links": {
          "self": "/api/v2/comments/32/relationships/comment-revisions",
          "related": "/api/v2/comments/32/comment-revisions"
        }
      }
    }
  }
}