Comment

A comment is a reader's response to an article in a blog. Comments appear on the article page in reverse chronological order, typically after the article body. Just as a blog can have any number of articles, an article can have any number of comments.

Comment

Article comments are a target for spammers, so Shopify blogs use a spam detection system to identify comments that are likely to be spam. Shop owners can also can mark comments as spam or not spam. Comments that are marked as spam are removed from the Shopify admin and don't appear in the blog.

What you can do with Comment

The Shopify API lets you do the following with the Comment resource. More detailed versions of these general actions may be available:

Comment properties

article_id
"article_id": 134645308

A unique numeric identifier for the article that the comment belongs to.

author
"author": "Soleone"

The name of the author of the comment.

blog_id
"blog_id": 241253187

A unique numeric identifier for the blog containing the article that the comment belongs to.

body
"body": "This is a _great_ article."

The basic Textile markup of a comment.

body_html
"body_html": "<p>This is a <em>great</em> article.</p>"

The text of the comment, complete with HTML markup.

created_at
"created_at": "2012-08-24T14:01:46-04:00"

The date and time (ISO 8601 format) when the comment was created.

email
"email": "sole@one.de"

The email address of the author of the comment.

id
"id": 653537639

A unique numeric identifier for the comment.

ip
"ip": "127.0.0.1"

The IP address from which the comment was posted.

published_at
"published_at": "2012-08-24T14:02:00-04:00"

The date and time (ISO 8601 format) when the comment was published.

status
"status": "unapproved"

The status of the comment. Valid values:

  • pending: The comment has been created but is awaiting spam detection. Depending on the result of the spam detection and the shop owner's comment preferences, this property will be transitioned to either spam, unapproved, or approved.
  • unapproved (default): The comment is awaiting approval by the shop owner. It's not visible to the readers of the blog.
  • published: The comment has been approved (if the blog requires comments to be approved) and is visible to readers of the blog.
  • spam: The comment has been marked as spam and removed from the Shopify admin. It's not visible to readers of the blog.
  • removed: The comment has been removed by the shop owner. It's not visible to readers of the blog.

updated_at
"updated_at": "2012-08-24T14:02:00-04:00"

The date and time (ISO 8601 format) when the comment was last modified. When the comment is created, this matches the value of created_at. If the blog requires comments to be approved, then this value is updated to the date and time when the comment is approved.

user_agent
"user_agent": "Mozilla/5.0"

The user agent string provided by the software used to create the comment (usually a browser).

Endpoints

GET /admin/comments.json
Retrieves a list of comments
limit

The maximum number of results to retrieve.

(default: 50) (maximum: 250)
page

The page of results to show.

(default: 1)
since_id

Restrict results to after the specified ID.

created_at_min

Show comments created after date (format: 2014-04-25T16:15:47-04:00).

created_at_max

Show comments created before date (format: 2014-04-25T16:15:47-04:00).

updated_at_min

Show comments last updated after date (format: 2014-04-25T16:15:47-04:00).

updated_at_max

Show comments last updated before date (format: 2014-04-25T16:15:47-04:00).

published_at_min

Show comments published after date (format: 2014-04-25T16:15:47-04:00).

published_at_max

Show comments published before date (format: 2014-04-25T16:15:47-04:00).

fields

Show only certain fields, specified by a comma-separated list of field names.

published_status

Filter results by their published status.

(default: any)
  • published: Show only published comments.
  • unpublished: Show only unpublished comments.
  • any: Show comments of any published status.
status

Filter results by their status.

  • pending: Show only pending comments.
  • published: Show only published comments.
  • unapproved: Show only unapproved comments.

Retrieve all the comments for a certain article of a blog

GET /admin/comments.json?article_id=134645308&blog_id=241253187
View Response
HTTP/1.1 200 OK
{
  "comments": [
    {
      "id": 653537639,
      "body": "Hi author, I really _like_ what you're doing there.",
      "body_html": "<p>Hi author, I really <em>like</em> what you're doing there.</p>",
      "author": "Soleone",
      "email": "sole@one.de",
      "status": "unapproved",
      "article_id": 134645308,
      "blog_id": 241253187,
      "created_at": "2018-04-06T10:52:09-04:00",
      "updated_at": "2018-04-06T10:52:09-04:00",
      "ip": "127.0.0.1",
      "user_agent": "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_4; en-us) AppleWebKit/525.18 (KHTML, like Gecko) Version/3.1.2 Safari/525.20.1",
      "published_at": null
    },
    {
      "id": 118373535,
      "body": "Hi author, I really _like_ what you're doing there.",
      "body_html": "<p>Hi author, I really <em>like</em> what you're doing there.</p>",
      "author": "Soleone",
      "email": "sole@one.de",
      "status": "published",
      "article_id": 134645308,
      "blog_id": 241253187,
      "created_at": "2018-04-06T10:52:09-04:00",
      "updated_at": "2018-04-06T10:52:09-04:00",
      "ip": "127.0.0.1",
      "user_agent": "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_4; en-us) AppleWebKit/525.18 (KHTML, like Gecko) Version/3.1.2 Safari/525.20.1",
      "published_at": null
    }
  ]
}

Retrieve all the comments for all the articles of a blog

GET /admin/comments.json?blog_id=241253187
View Response
HTTP/1.1 200 OK
{
  "comments": [
    {
      "id": 653537639,
      "body": "Hi author, I really _like_ what you're doing there.",
      "body_html": "<p>Hi author, I really <em>like</em> what you're doing there.</p>",
      "author": "Soleone",
      "email": "sole@one.de",
      "status": "unapproved",
      "article_id": 134645308,
      "blog_id": 241253187,
      "created_at": "2018-04-06T10:52:09-04:00",
      "updated_at": "2018-04-06T10:52:09-04:00",
      "ip": "127.0.0.1",
      "user_agent": "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_4; en-us) AppleWebKit/525.18 (KHTML, like Gecko) Version/3.1.2 Safari/525.20.1",
      "published_at": null
    },
    {
      "id": 118373535,
      "body": "Hi author, I really _like_ what you're doing there.",
      "body_html": "<p>Hi author, I really <em>like</em> what you're doing there.</p>",
      "author": "Soleone",
      "email": "sole@one.de",
      "status": "published",
      "article_id": 134645308,
      "blog_id": 241253187,
      "created_at": "2018-04-06T10:52:09-04:00",
      "updated_at": "2018-04-06T10:52:09-04:00",
      "ip": "127.0.0.1",
      "user_agent": "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_4; en-us) AppleWebKit/525.18 (KHTML, like Gecko) Version/3.1.2 Safari/525.20.1",
      "published_at": null
    }
  ]
}

Retrieve all the comments for this shop

GET /admin/comments.json
View Response
HTTP/1.1 200 OK
{
  "comments": [
    {
      "id": 653537639,
      "body": "Hi author, I really _like_ what you're doing there.",
      "body_html": "<p>Hi author, I really <em>like</em> what you're doing there.</p>",
      "author": "Soleone",
      "email": "sole@one.de",
      "status": "unapproved",
      "article_id": 134645308,
      "blog_id": 241253187,
      "created_at": "2018-04-06T10:52:09-04:00",
      "updated_at": "2018-04-06T10:52:09-04:00",
      "ip": "127.0.0.1",
      "user_agent": "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_4; en-us) AppleWebKit/525.18 (KHTML, like Gecko) Version/3.1.2 Safari/525.20.1",
      "published_at": null
    },
    {
      "id": 118373535,
      "body": "Hi author, I really _like_ what you're doing there.",
      "body_html": "<p>Hi author, I really <em>like</em> what you're doing there.</p>",
      "author": "Soleone",
      "email": "sole@one.de",
      "status": "published",
      "article_id": 134645308,
      "blog_id": 241253187,
      "created_at": "2018-04-06T10:52:09-04:00",
      "updated_at": "2018-04-06T10:52:09-04:00",
      "ip": "127.0.0.1",
      "user_agent": "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_4; en-us) AppleWebKit/525.18 (KHTML, like Gecko) Version/3.1.2 Safari/525.20.1",
      "published_at": null
    }
  ]
}

Retrieve all comments for this shop after the specified ID

GET /admin/comments.json?since_id=118373535
View Response
HTTP/1.1 200 OK
{
  "comments": [
    {
      "id": 653537639,
      "body": "Hi author, I really _like_ what you're doing there.",
      "body_html": "<p>Hi author, I really <em>like</em> what you're doing there.</p>",
      "author": "Soleone",
      "email": "sole@one.de",
      "status": "unapproved",
      "article_id": 134645308,
      "blog_id": 241253187,
      "created_at": "2018-04-06T10:52:09-04:00",
      "updated_at": "2018-04-06T10:52:09-04:00",
      "ip": "127.0.0.1",
      "user_agent": "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_4; en-us) AppleWebKit/525.18 (KHTML, like Gecko) Version/3.1.2 Safari/525.20.1",
      "published_at": null
    }
  ]
}
GET /admin/comments/count.json
Retrieves a count of comments
created_at_min

Count comments created after date (format: 2014-04-25T16:15:47-04:00).

created_at_max

Count comments created before date (format: 2014-04-25T16:15:47-04:00).

updated_at_min

Count comments last updated after date (format: 2014-04-25T16:15:47-04:00).

updated_at_max

Count comments last updated before date (format: 2014-04-25T16:15:47-04:00).

published_at_min

Count comments published after date (format: 2014-04-25T16:15:47-04:00).

published_at_max

Count comments published before date (format: 2014-04-25T16:15:47-04:00).

published_status

Retrieve a count of comments with a given published status.

(default: any)
  • published: Count only published comments.
  • unpublished: Count only unpublished comments.
  • any: Count comments of any published status.
status

Retrieve a count of comments with a given status.

  • pending: Count pending comments.
  • published: Count published comments.
  • unapproved: Count unapproved comments.

Count all comments for a certain article of a blog

GET /admin/comments/count.json?article_id=134645308&blog_id=241253187
View Response
HTTP/1.1 200 OK
{
  "count": 2
}

Count all the comments for all the articles of a blog

GET /admin/comments/count.json?blog_id=241253187
View Response
HTTP/1.1 200 OK
{
  "count": 2
}

Count all the comments for this shop

GET /admin/comments/count.json
View Response
HTTP/1.1 200 OK
{
  "count": 2
}
GET /admin/comments/118373535.json
Retrieves a single comment by its ID
fields

Show only certain fields, specified by a comma-separated list of field names.

Retrieve a single comment

GET /admin/comments/#{comment_id}.json
View Response
HTTP/1.1 200 OK
{
  "comment": {
    "id": 118373535,
    "body": "Hi author, I really _like_ what you're doing there.",
    "body_html": "<p>Hi author, I really <em>like</em> what you're doing there.</p>",
    "author": "Soleone",
    "email": "sole@one.de",
    "status": "published",
    "article_id": 134645308,
    "blog_id": 241253187,
    "created_at": "2018-04-06T10:52:09-04:00",
    "updated_at": "2018-04-06T10:52:09-04:00",
    "ip": "127.0.0.1",
    "user_agent": "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_4; en-us) AppleWebKit/525.18 (KHTML, like Gecko) Version/3.1.2 Safari/525.20.1",
    "published_at": null
  }
}
POST /admin/comments.json
Creates a comment for an article

Create a comment for an article of a blog using basic Textile markup

POST /admin/comments.json
{
  "comment": {
    "body": "I like comments\nAnd I like posting them *RESTfully*.",
    "author": "Your name",
    "email": "your@email.com",
    "ip": "107.20.160.121",
    "blog_id": 241253187,
    "article_id": 134645308
  }
}
View Response
HTTP/1.1 201 Created
{
  "comment": {
    "id": 757536379,
    "body": "I like comments\nAnd I like posting them *RESTfully*.",
    "body_html": "<p>I like comments<br />\nAnd I like posting them <strong>RESTfully</strong>.</p>",
    "author": "Your name",
    "email": "your@email.com",
    "status": "pending",
    "article_id": 134645308,
    "blog_id": 241253187,
    "created_at": "2018-04-06T10:52:54-04:00",
    "updated_at": "2018-04-06T10:52:54-04:00",
    "ip": "107.20.160.121",
    "user_agent": null,
    "published_at": "2018-04-06T10:52:54-04:00"
  }
}

Creating a comment without a body, author, and email fails and returns an error

POST /admin/comments.json
{
  "comment": {
    "article_id": 134645308
  }
}
View Response
HTTP/1.1 422 Unprocessable Entity
{
  "errors": {
    "author": [
      "can't be blank"
    ],
    "body": [
      "can't be blank"
    ],
    "email": [
      "is invalid"
    ]
  }
}
PUT /admin/comments/118373535.json
Updates a comment of an article

Update the body of an existing comment

PUT /admin/comments/#{comment_id}.json
{
  "comment": {
    "id": 118373535,
    "body": "You can even update through a web service.",
    "author": "Your new name",
    "email": "your@updated-email.com",
    "published_at": "2018-04-06T14:52:55.316Z"
  }
}
View Response
HTTP/1.1 200 OK
{
  "comment": {
    "id": 118373535,
    "body": "You can even update through a web service.",
    "body_html": "<p>You can even update through a web service.</p>",
    "author": "Your new name",
    "email": "your@updated-email.com",
    "status": "published",
    "article_id": 134645308,
    "blog_id": 241253187,
    "created_at": "2018-04-06T10:52:09-04:00",
    "updated_at": "2018-04-06T10:52:55-04:00",
    "ip": "127.0.0.1",
    "user_agent": "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_4; en-us) AppleWebKit/525.18 (KHTML, like Gecko) Version/3.1.2 Safari/525.20.1",
    "published_at": "2018-04-06T10:52:55-04:00"
  }
}
POST /admin/comments/653537639/spam.json
Marks a comment as spam

Mark a comment as spam

POST /admin/comments/#{comment_id}/spam.json
{
}
View Response
HTTP/1.1 200 OK
{
  "id": 653537639,
  "body": "Hi author, I really _like_ what you're doing there.",
  "body_html": "<p>Hi author, I really <em>like</em> what you're doing there.</p>",
  "author": "Soleone",
  "email": "sole@one.de",
  "status": "spam",
  "article_id": 134645308,
  "blog_id": 241253187,
  "created_at": "2018-04-06T10:52:09-04:00",
  "updated_at": "2018-04-06T10:52:56-04:00",
  "ip": "127.0.0.1",
  "user_agent": "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_4; en-us) AppleWebKit/525.18 (KHTML, like Gecko) Version/3.1.2 Safari/525.20.1",
  "published_at": "2018-04-06T10:52:56-04:00"
}
POST /admin/comments/653537639/not_spam.json
Marks a comment as not spam

Mark a comment as not spam, restoring it to an unapproved or published state

POST /admin/comments/#{comment_id}/not_spam.json
{
}
View Response
HTTP/1.1 200 OK
{
  "id": 653537639,
  "body": "Hi author, I really _like_ what you're doing there.",
  "body_html": "<p>Hi author, I really <em>like</em> what you're doing there.</p>",
  "author": "Soleone",
  "email": "sole@one.de",
  "status": "published",
  "article_id": 134645308,
  "blog_id": 241253187,
  "created_at": "2018-04-06T10:52:09-04:00",
  "updated_at": "2018-04-06T10:52:56-04:00",
  "ip": "127.0.0.1",
  "user_agent": "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_4; en-us) AppleWebKit/525.18 (KHTML, like Gecko) Version/3.1.2 Safari/525.20.1",
  "published_at": "2018-04-06T10:52:56-04:00"
}
POST /admin/comments/653537639/approve.json
Approves a comment

Approve a comment and publish it to the blog

POST /admin/comments/#{comment_id}/approve.json
{
}
View Response
HTTP/1.1 200 OK
{
  "id": 653537639,
  "body": "Hi author, I really _like_ what you're doing there.",
  "body_html": "<p>Hi author, I really <em>like</em> what you're doing there.</p>",
  "author": "Soleone",
  "email": "sole@one.de",
  "status": "published",
  "article_id": 134645308,
  "blog_id": 241253187,
  "created_at": "2018-04-06T10:52:09-04:00",
  "updated_at": "2018-04-06T10:52:57-04:00",
  "ip": "127.0.0.1",
  "user_agent": "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_4; en-us) AppleWebKit/525.18 (KHTML, like Gecko) Version/3.1.2 Safari/525.20.1",
  "published_at": "2018-04-06T10:52:57-04:00"
}
POST /admin/comments/653537639/remove.json
Removes a comment

Remove a comment

POST /admin/comments/#{comment_id}/remove.json
{
}
View Response
HTTP/1.1 200 OK
{
  "id": 653537639,
  "body": "Hi author, I really _like_ what you're doing there.",
  "body_html": "<p>Hi author, I really <em>like</em> what you're doing there.</p>",
  "author": "Soleone",
  "email": "sole@one.de",
  "status": "removed",
  "article_id": 134645308,
  "blog_id": 241253187,
  "created_at": "2018-04-06T10:52:09-04:00",
  "updated_at": "2018-04-06T10:52:57-04:00",
  "ip": "127.0.0.1",
  "user_agent": "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_4; en-us) AppleWebKit/525.18 (KHTML, like Gecko) Version/3.1.2 Safari/525.20.1",
  "published_at": "2018-04-06T10:52:57-04:00"
}
POST /admin/comments/653537639/restore.json
Restores a previously removed comment

Restore a removed comment

POST /admin/comments/#{comment_id}/restore.json
{
}
View Response
HTTP/1.1 200 OK
{
  "id": 653537639,
  "body": "Hi author, I really _like_ what you're doing there.",
  "body_html": "<p>Hi author, I really <em>like</em> what you're doing there.</p>",
  "author": "Soleone",
  "email": "sole@one.de",
  "status": "published",
  "article_id": 134645308,
  "blog_id": 241253187,
  "created_at": "2018-04-06T10:52:09-04:00",
  "updated_at": "2018-04-06T10:52:57-04:00",
  "ip": "127.0.0.1",
  "user_agent": "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_4; en-us) AppleWebKit/525.18 (KHTML, like Gecko) Version/3.1.2 Safari/525.20.1",
  "published_at": "2018-04-06T10:52:57-04:00"
}