Edit
Table of Contents
- 01. Record field format
- 02. Associated attributes
- 03. Index
- 04. Show
- 05. Create
- 06. Update
- 07. Destroy
- 08. Undelete
- 09. See also
- 10. External links
This page has details for how to interact with comment records through the API.
01 Record field format
| Name | Type | Details |
|---|---|---|
id | integer | >0 |
post_id | integer | >0 |
body | string | |
score | integer | |
is_deleted | boolean | |
is_sticky | boolean | |
do_not_bump_post | boolean | |
creator_id | integer | >0 |
updater_id | integer | >0 |
created_at | timestamp | |
updated_at | timestamp |
02 Associated attributes
The following is the list of relations that can be included in the API results (see Help:Common URL parameters for more info):
| Name | Type | Number | Availability | Details |
|---|---|---|---|---|
creator | user | single | required | |
updater | user | single | required | |
post | post | single | required |
03 Index
Returns multiple comment records.
| HTTP Method | GET |
| Base URL | /comments.json |
| Type | read request |
| Description | The default order is ID descending. |
Note: group_by as a parameter must be set to comment, or else posts will be returned instead (e.g. group_by=comment).
Search attributes
Search parameters take the following format (see Help:Common URL parameters for more info):
search[FIELD]=VALUE
The following are the base fields along with their associated type. Check the syntax pages for all of the available variations.
- Number syntax
idscorecreated_atupdated_at- Text syntax
body- Boolean syntax
is_deletedis_stickydo_not_bump_post- Post syntax
post- User syntax
creatorupdater
Special search parameters
The following are additional search fields.
is_edited- Whether a comment was edited 5 or more minutes it was created. (see Help:Boolean Syntax)
Search order
Using the search parameter order with one of the following values changes the order of the results.
id_asc- ID ascending.created_at- Created at descending.created_at_desc- Created at descending.created_at_asc- Created at ascending.post_id- Post ID descending.post_id_desc- Post ID descending.score- Post ID descending.score_desc- Post ID descending.score_asc- Post ID ascending.updated_at- Updated at descending.updated_at_desc- Updated at descending.updated_at_asc- Updated at ascending.custom- Ordered bysearch[id]. (See Help:Common URL parameters for more info)
04 Show
Returns a single comment record.
| HTTP Method | GET |
| Base URL | /comments/$id.json |
| Type | read request |
| Description | $id is the comment ID. |
05 Create
Creates a single comment record.
| HTTP Method | POST |
| Base URL | /comments.json |
| Type | write request |
Create parameters
Comment parameters take the following format (see Help:API Write Requests for more info):
comment[FIELD]=VALUE
- Required:
post_idbody- Optional
do_not_bump_postis_sticky(Moderator+)
06 Update
Updates a single comment record.
| HTTP Method | PUT/PATCH |
| Base URL | /comments/$id.json |
| Type | write request |
| Description | $id is the comment ID. |
Update parameters
- Optional:
bodyis_deletedis_sticky(Moderator+)
07 Destroy
Deletes a single comment record.
| HTTP Method | DELETE |
| Base URL | /comments/$id.json |
| Type | write request |
| Description | $id is the comment ID. |
Note: This action can also be accomplished using Update by setting is_deleted to true.
08 Undelete
Undeletes a single comment record.
| HTTP Method | POST |
| Base URL | /comments/$id/undelete.json |
| Type | write request |
| Description | $id is the comment ID. |
Note: This action can also be accomplished using Update by setting is_deleted to false.
09 See also
10 External links
No posts found.
