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": 127668,
    "site_ID": 3584907,
    "comments": [
        {
            "ID": 409270,
            "post": {
                "ID": 40369,
                "title": "Transfer Your Existing Domain to WordPress.com",
                "type": "post",
                "link": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/posts\/40369"
            },
            "author": {
                "ID": 0,
                "login": "",
                "email": false,
                "name": "Andrija Vucinic",
                "first_name": "",
                "last_name": "",
                "nice_name": "",
                "URL": "http:\/\/andrija.me",
                "avatar_URL": "https:\/\/0.gravatar.com\/avatar\/3462bba9b26e49bf86eb1b819b23e423?s=96&d=retro",
                "profile_URL": "https:\/\/en.gravatar.com\/3462bba9b26e49bf86eb1b819b23e423",
                "ip_address": false
            },
            "date": "2018-05-20T10:19:43+00:00",
            "URL": "http:\/\/en.blog.wordpress.com\/2018\/05\/14\/transfer-your-existing-domain-to-wordpress-com\/#comment-409270",
            "short_URL": "https:\/\/wp.me\/pf2B5-av7%23comment-409270",
            "content": "<blockquote><p>If you could add multi year renewals for domain registration and domain mapping it would be great.<\/p><\/blockquote>\n<p>We already have the technical foundations, and talked about it internally a few times. I can’t give you an ETA, but it’s definitely coming.<\/p>\n<blockquote><p>I however have an antique upgrade with just the domain mapping and would like to keep the mapping into the future as I have for the domain registration.<\/p><\/blockquote>\n<p>No need to worry, all your existing upgrades can be renewed without a plan.<\/p>\n<blockquote><p>The bundles might make multi-year a bit expensive for some people as when I helped in the forum there were people that wanted domain mapping and registration but struggled with just those two upgrades, I think about $25 a year back then, but nice feature.<\/p><\/blockquote>\n<p>For new users, a plan is required to be able to register or map a domain to a site. With that in mind, we introduced the Personal plan for 48$, which includes a domain registration\/mapping for free.<\/p>\n",
            "raw_content": "<blockquote>If you could add multi year renewals for domain registration and domain mapping it would be great.<\/blockquote>\r\n\r\n\r\nWe already have the technical foundations, and talked about it internally a few times. I can't give you an ETA, but it's definitely coming.\r\n\r\n\r\n<blockquote>I however have an antique upgrade with just the domain mapping and would like to keep the mapping into the future as I have for the domain registration.<\/blockquote>\r\n\r\nNo need to worry, all your existing upgrades can be renewed without a plan.\r\n\r\n\r\n<blockquote>The bundles might make multi-year a bit expensive for some people as when I helped in the forum there were people that wanted domain mapping and registration but struggled with just those two upgrades, I think about $25 a year back then, but nice feature.<\/blockquote>\r\n\r\nFor new users, a plan is required to be able to register or map a domain to a site. With that in mind, we introduced the Personal plan for 48$, which includes a domain registration\/mapping for free.",
            "status": "approved",
            "parent": {
                "ID": 409193,
                "type": "comment",
                "link": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/409193"
            },
            "type": "comment",
            "like_count": 2,
            "i_like": false,
            "meta": {
                "links": {
                    "self": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/409270",
                    "help": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/409270\/help",
                    "site": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907",
                    "post": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/posts\/40369",
                    "replies": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/409270\/replies\/",
                    "likes": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/409270\/likes\/"
                }
            },
            "can_moderate": false
        },
        {
            "ID": 409258,
            "post": {
                "ID": 40486,
                "title": "New Privacy Features and Updated Policies",
                "type": "post",
                "link": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/posts\/40486"
            },
            "author": {
                "ID": 0,
                "login": "",
                "email": false,
                "name": "deepanilamani",
                "first_name": "",
                "last_name": "",
                "nice_name": "",
                "URL": "https:\/\/iammypath.wordpress.com",
                "avatar_URL": "https:\/\/0.gravatar.com\/avatar\/cc7d79fdfb75854f59bbe3566a63280b?s=96&d=retro",
                "profile_URL": "https:\/\/en.gravatar.com\/cc7d79fdfb75854f59bbe3566a63280b",
                "ip_address": false
            },
            "date": "2018-05-18T10:16:55+00:00",
            "URL": "http:\/\/en.blog.wordpress.com\/2018\/05\/14\/new-privacy-features-and-updated-policies\/#comment-409258",
            "short_URL": "https:\/\/wp.me\/pf2B5-ax0%23comment-409258",
            "content": "<p>Thank you for all the information. Grateful for the new privacy features you have added to the blogs for our safety \ud83d\ude42<\/p>\n",
            "raw_content": "Thank you for all the information. Grateful for the new privacy features you have added to the blogs for our safety :)",
            "status": "approved",
            "parent": false,
            "type": "comment",
            "like_count": 3,
            "i_like": false,
            "meta": {
                "links": {
                    "self": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/409258",
                    "help": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/409258\/help",
                    "site": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907",
                    "post": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/posts\/40486",
                    "replies": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/409258\/replies\/",
                    "likes": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/409258\/likes\/"
                }
            },
            "can_moderate": false
        }
    ]
}