GET /sites/$site/comments/

Get a list of recent comments.

Resource Information

   
Method GET
URL https://public-api.wordpress.com/rest/v1.1/sites/$site/comments/
Requires authentication? No

Method Parameters

Parameter Type Description
$site (int|string) Site ID or domain

Query Parameters

Parameter Type Description
context (string)
display:
(default) Formats the output as HTML for display. Shortcodes are parsed, paragraph tags are added, etc..
edit:
Formats the output for editing. Shortcodes are left unparsed, significant whitespace is kept, etc..
http_envelope (bool)
false:
(default)
true:
Some environments (like in-browser JavaScript or Flash) block or divert responses with a non-200 HTTP status code. Setting this parameter will force the HTTP status code to always be 200. The JSON response is wrapped in an "envelope" containing the "real" HTTP status code and headers.
pretty (bool)
false:
(default)
true:
Output pretty JSON
meta (string) Optional. Loads data from the endpoints found in the 'meta' part of the response. Comma-separated list. Example: meta=site,likes
fields (string) Optional. Returns specified fields only. Comma-separated list. Example: fields=ID,title
callback (string) An optional JSONP callback function.
number (int) The number of comments to return. Limit: 100. When using hierarchical=1, number refers to the number of top-level comments returned. Default: 20.
offset (int) 0-indexed offset. Not available if using hierarchical=1.
page (int) Return the Nth 1-indexed page of comments. Takes precedence over the offset parameter. When using hierarchical=1, pagination is a bit different. See the note on the number parameter.
order (string)
DESC:
(default) Return comments in descending order from newest to oldest.
ASC:
Return comments in ascending order from oldest to newest.
hierarchical (bool)
false:
(default)
true:
(BETA) Order the comment list hierarchically.
after (iso 8601 datetime) Return comments dated on or after the specified datetime. Not available if using hierarchical=1.
before (iso 8601 datetime) Return comments dated on or before the specified datetime. Not available if using hierarchical=1.
type (string)
any:
(default) Return all comments regardless of type.
comment:
Return only regular comments.
trackback:
Return only trackbacks.
pingback:
Return only pingbacks.
pings:
Return both trackbacks and pingbacks.
status (string)
approved:
(default) Return only approved comments.
unapproved:
Return only comments in the moderation queue.
spam:
Return only comments marked as spam.
trash:
Return only comments in the trash.
all:
Return comments of all statuses.

Response Parameters

Parameter Type Description
found (int) The total number of comments found that match the request (ignoring limits, offsets, and pagination).
site_ID (int) The site ID
comments (array) An array of comment objects.

Resource Errors

These are the possible errors returned by this endpoint.

HTTP Code Error Identifier Error Message
403 unauthorized User cannot view post
403 unauthorized User cannot access this private blog.
403 unauthorized User cannot access this restricted blog
403 unauthorized User cannot read unapproved comment
403 unauthorized User cannot edit comment
403 unauthorized User cannot read non-approved comments
404 unknown_comment Unknown comment
400 invalid_context Invalid API CONTEXT
404 unknown_post Unknown post
400 invalid_number The NUMBER parameter must be less than or equal to 100.

Example

curl 'https://public-api.wordpress.com/rest/v1/sites/en.blog.wordpress.com/comments/?number=2'
<?php
$options  = array (
  'http' => 
  array (
    'ignore_errors' => true,
  ),
);

$context  = stream_context_create( $options );
$response = file_get_contents(
	'https://public-api.wordpress.com/rest/v1/sites/en.blog.wordpress.com/comments/?number=2',
	false,
	$context
);
$response = json_decode( $response );
?>

Response

{
    "found": 127962,
    "site_ID": 3584907,
    "comments": [
        {
            "ID": 409848,
            "post": {
                "ID": 40626,
                "title": "Introducing: A Diverse, Free Stock Photo Library",
                "type": "post",
                "link": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/posts\/40626"
            },
            "author": {
                "ID": 0,
                "login": "",
                "email": false,
                "name": "Derek Brown",
                "first_name": "",
                "last_name": "",
                "nice_name": "",
                "URL": "https:\/\/plus.google.com\/102775916360254140075",
                "avatar_URL": "https:\/\/i0.wp.com\/lh5.googleusercontent.com\/-WRKwdTs00tI\/AAAAAAAAAAI\/AAAAAAAABJY\/G5ynUASJcyo\/photo.jpg?resize=96%2C96&ssl=1",
                "profile_URL": "https:\/\/en.gravatar.com\/4305965795821161da691d58d0321677",
                "ip_address": false
            },
            "date": "2018-08-07T06:53:46+00:00",
            "URL": "http:\/\/en.blog.wordpress.com\/2018\/08\/02\/diverse-stock-photo-library-pexels\/#comment-409848",
            "short_URL": "https:\/\/wp.me\/pf2B5-azg%23comment-409848",
            "content": "<p>I’d like to follow-up on something minababe said, but from a little different angle.<\/p>\n<p>I have an agency, we’ve manage over 1,500 WordPress sites, and have built many more than that. Part of this involves the stock photos we use on their sites. We license from Getty and others but are always looking for more cost effective approaches.<\/p>\n<p>Over the years I have on a couple of occasions been contacted by Getty claiming rights to an image that we’re using on a client website. We are hard core about usimg propertly licenses images, we spend over $1,000 a month with Getty alone. None of the stock photo sites have good audit trails of image provenance and our transaction history. Getty will say “show us a screenshot of the download” – this is for one image of thousands over 5 years or something. Guilty until proven innocent. <\/p>\n<p>So with that background here’s my question: If Getty comes along a few years from now and says an image belonged to them, I assume there’s no real recourse for my business either with WordPress.com, or Pexels, or the supposed original photographer. My license with Getty provides for some indemnification in the event someone other than Getty claims copyright from an image I licensed from Getty, but it seems there’s nothing of the sort here. <\/p>\n<p>One other angle, again a tangent of minababe. There was a case a few years back where Getty bought a collection of open source images, and then started finding uses of those images that predated the acquisition, but demanding money. Getty has bots that crawl the web, and I suspect bots that send demand for payment letters. They just harass people, no one has the documentation they require, so you just pay. <\/p>\n<p>OK that was half a rant on Getty, don’t get me going more or you’re get the whole rant \ud83d\ude42  But my question is still about my liability of using these free images at some point in the future. <\/p>\n<p>Thanks for any insight on this.<br \/>\nDerek<\/p>\n",
            "raw_content": "I'd like to follow-up on something minababe said, but from a little different angle.\r\n\r\nI have an agency, we've manage over 1,500 WordPress sites, and have built many more than that. Part of this involves the stock photos we use on their sites. We license from Getty and others but are always looking for more cost effective approaches.\r\n\r\nOver the years I have on a couple of occasions been contacted by Getty claiming rights to an image that we're using on a client website. We are hard core about usimg propertly licenses images, we spend over $1,000 a month with Getty alone. None of the stock photo sites have good audit trails of image provenance and our transaction history. Getty will say \"show us a screenshot of the download\" - this is for one image of thousands over 5 years or something. Guilty until proven innocent. \r\n\r\nSo with that background here's my question: If Getty comes along a few years from now and says an image belonged to them, I assume there's no real recourse for my business either with WordPress.com, or Pexels, or the supposed original photographer. My license with Getty provides for some indemnification in the event someone other than Getty claims copyright from an image I licensed from Getty, but it seems there's nothing of the sort here. \r\n\r\nOne other angle, again a tangent of minababe. There was a case a few years back where Getty bought a collection of open source images, and then started finding uses of those images that predated the acquisition, but demanding money. Getty has bots that crawl the web, and I suspect bots that send demand for payment letters. They just harass people, no one has the documentation they require, so you just pay. \r\n\r\nOK that was half a rant on Getty, don't get me going more or you're get the whole rant 🙂  But my question is still about my liability of using these free images at some point in the future. \r\n\r\nThanks for any insight on this. \r\nDerek",
            "status": "approved",
            "parent": false,
            "type": "comment",
            "like_count": 2,
            "i_like": false,
            "meta": {
                "links": {
                    "self": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/409848",
                    "help": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/409848\/help",
                    "site": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907",
                    "post": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/posts\/40626",
                    "replies": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/409848\/replies\/",
                    "likes": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/409848\/likes\/"
                }
            },
            "can_moderate": false
        },
        {
            "ID": 409842,
            "post": {
                "ID": 40626,
                "title": "Introducing: A Diverse, Free Stock Photo Library",
                "type": "post",
                "link": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/posts\/40626"
            },
            "author": {
                "ID": 0,
                "login": "",
                "email": false,
                "name": "Lauren Miller",
                "first_name": "",
                "last_name": "",
                "nice_name": "",
                "URL": "http:\/\/www.laurenjoanmiller.com",
                "avatar_URL": "https:\/\/1.gravatar.com\/avatar\/aed8d134316220986e8a75464b700677?s=96&d=retro",
                "profile_URL": "https:\/\/en.gravatar.com\/aed8d134316220986e8a75464b700677",
                "ip_address": false
            },
            "date": "2018-08-06T13:55:49+00:00",
            "URL": "http:\/\/en.blog.wordpress.com\/2018\/08\/02\/diverse-stock-photo-library-pexels\/#comment-409842",
            "short_URL": "https:\/\/wp.me\/pf2B5-azg%23comment-409842",
            "content": "<p>This is such a forward-thinking idea for WordPress and will make the lives of so many bloggers a bit easier, being able to import directly from Pexels. It’s a wonderful addition and just reaffirms that you care about your users. God bless!<\/p>\n",
            "raw_content": "This is such a forward-thinking idea for WordPress and will make the lives of so many bloggers a bit easier, being able to import directly from Pexels. It's a wonderful addition and just reaffirms that you care about your users. God bless!",
            "status": "approved",
            "parent": false,
            "type": "comment",
            "like_count": 2,
            "i_like": false,
            "meta": {
                "links": {
                    "self": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/409842",
                    "help": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/409842\/help",
                    "site": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907",
                    "post": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/posts\/40626",
                    "replies": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/409842\/replies\/",
                    "likes": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/409842\/likes\/"
                }
            },
            "can_moderate": false
        }
    ]
}