Comment

A comment is a reader's response to an article in a blog. They appear on the article page in chronological order, typically after the article body.

Comment

Just as a blog can have any number of articles, an article can have any number of comments. Blog comments are a target for spammers, so Shopify's blogs make use of a spam detection system to identify comments that are likely to be spam. Shop owners can mark comments as spam and not spam, which not only hides or unhides them from the readers' view, but also trains the Shopify spam detection system.

What can you 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 to which the comment belongs.

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" : "I really _like_ this." }

The basic textile markup of a comment.

body_html
{ "body_html" : "<p> I really <em>like</em> this.</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 when the comment was created. The API returns this value in ISO 8601 format.

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 when the comment was published. In the case of comments, this is the date and time when the comment was created, meaning that it has the same value as created_at. The API returns this value in ISO 8601 format.

status
{ "status" : "removed" }

The status of the comment. The possible values are:

  • unapproved (default): The comment is awaiting moderation by the shop owner and is not visible to the readers of the blog.
  • published: The comment has been approved (if the blog requires comments to be moderated) and is visible to readers of the blog.
  • spam: The comment has been marked as spam by the shop owner and is not visible to readers of the blog.
  • removed: The comment has been removed from the article.

updated_at
{ "updated_at" : null }

The date and time when the comment was last modified. When the comment is first created, this is the date and time when the comment was created, meaning that it has the same value as created_at. If the blog requires comments to be approved, this value is updated to the date and time the comment was approved upon approval. The API returns this value in ISO 8601 format.

user_agent
{ "user_agent" : "Mozilla/5.0" }

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

Endpoints

GET /admin/comments.json

Get a list of all comments for an article

limit

Amount of results

(default: 50) (maximum: 250)
page

Page 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

comma-separated list of fields to include in the response

published_status
  • published - Show only published comments
  • unpublished - Show only unpublished comments
  • any - Show all comments (default)
status
  • pending - All pending comments
  • published - Show only published comments
  • unapproved - Show only unapproved comments

Get all comments 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": "2016-11-09T13:42:07-05:00",
      "updated_at": "2016-11-09T13:42:07-05: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 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": "2016-11-09T13:42:07-05:00",
      "updated_at": "2016-11-09T13:42:07-05: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": "2016-11-09T13:42:07-05:00",
      "updated_at": "2016-11-09T13:42:07-05: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 all the comments for all the articles of a certain 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": "2016-11-09T13:42:07-05:00",
      "updated_at": "2016-11-09T13:42:07-05: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": "2016-11-09T13:42:07-05:00",
      "updated_at": "2016-11-09T13:42:07-05: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 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": "2016-11-09T13:42:07-05:00",
      "updated_at": "2016-11-09T13:42:07-05: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": "2016-11-09T13:42:07-05:00",
      "updated_at": "2016-11-09T13:42:07-05: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

Get a count of all comments for an article

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
  • published - Count only published comments
  • unpublished - Count only unpublished comments
  • any - Count all comments (default)
status
  • pending - All pending comments
  • published - Count only published comments
  • unapproved - Count only 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
}

Get a count of all the comments for all the articles of a certain blog

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

Get a count of 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

Get a single comment by its ID

fields

comma-separated list of fields to include in the response

Get a single comment

GET /admin/comments/#{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": "2016-11-09T13:42:07-05:00",
    "updated_at": "2016-11-09T13:42:07-05: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

Create a new comment for an article

Create a new comment with basic textile markup for a certain article of a blog

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": 757536352,
    "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": "2016-11-09T13:42:54-05:00",
    "updated_at": "2016-11-09T13:42:54-05:00",
    "ip": "107.20.160.121",
    "user_agent": null,
    "published_at": "2016-11-09T13:42:54-05:00"
  }
}

Trying to create a comment without a body, author, and email will return 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

Update a comment of an article within a blog

Update an existing comment body

PUT /admin/comments/#{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": "2016-11-09T18:42:55.227Z"
  }
}
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": "2016-11-09T13:42:07-05:00",
    "updated_at": "2016-11-09T13:42:55-05: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": "2016-11-09T13:42:55-05:00"
  }
}
POST /admin/comments/653537639/spam.json

Mark a comment as spam, helping to train our spam detection as well as remove the comment sometime soon

POST /admin/comments/#{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": "2016-11-09T13:42:07-05:00",
  "updated_at": "2016-11-09T13:42:52-05: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": "2016-11-09T13:42:52-05:00"
}
POST /admin/comments/653537639/not_spam.json

Mark a comment as not spam, restoring a comment marked as spam back to published

POST /admin/comments/#{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": "2016-11-09T13:42:07-05:00",
  "updated_at": "2016-11-09T13:42:56-05: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": "2016-11-09T13:42:56-05:00"
}
POST /admin/comments/653537639/approve.json

Approve a comment that is currently pending unapproved so that it will be published on the site

POST /admin/comments/#{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": "2016-11-09T13:42:07-05:00",
  "updated_at": "2016-11-09T13:42:52-05: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": "2016-11-09T13:42:52-05:00"
}
POST /admin/comments/653537639/remove.json

Remove a comment

POST /admin/comments/#{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": "2016-11-09T13:42:07-05:00",
  "updated_at": "2016-11-09T13:42:52-05: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": "2016-11-09T13:42:52-05:00"
}
POST /admin/comments/653537639/restore.json

Restore a Comment

POST /admin/comments/#{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": "2016-11-09T13:42:07-05:00",
  "updated_at": "2016-11-09T13:42:55-05: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": "2016-11-09T13:42:55-05:00"
}