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": 128636,
    "site_ID": 3584907,
    "comments": [
        {
            "ID": 411829,
            "post": {
                "ID": 41513,
                "title": "Want to See a More Diverse WordPress Contributor Community? So Do We.",
                "type": "post",
                "link": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/posts\/41513"
            },
            "author": {
                "ID": 0,
                "login": "",
                "email": false,
                "name": "Andrea Middleton",
                "first_name": "",
                "last_name": "",
                "nice_name": "",
                "URL": "https:\/\/thethingwiththestuff.wordpress.com\/",
                "avatar_URL": "https:\/\/2.gravatar.com\/avatar\/b38c7dd01895a969f236a5a699bfcce4?s=96&d=retro",
                "profile_URL": "https:\/\/en.gravatar.com\/b38c7dd01895a969f236a5a699bfcce4",
                "ip_address": false
            },
            "date": "2019-06-20T12:50:12+00:00",
            "URL": "http:\/\/en.blog.wordpress.com\/2019\/06\/19\/want-to-see-a-more-diverse-wordpress-contributor-community-so-do-we\/#comment-411829",
            "short_URL": "https:\/\/wp.me\/pf2B5-aNz%23comment-411829",
            "content": "<p>If your local WordPress meetup is organizing a workshop, then it’s definitely available to you! You can go to <a href=\"https:\/\/www.meetup.com\/pro\/wordpress\/\" rel=\"nofollow\">https:\/\/www.meetup.com\/pro\/wordpress\/<\/a> to find your local or nearest WordPress meetup group, and if they don’t have a workshop on the schedule \u2014 the meetups that have planned these workshops usually hold it once a year \u2014 then I encourage to ask them about organizing one. \ud83d\ude42<\/p>\n",
            "raw_content": "If your local WordPress meetup is organizing a workshop, then it's definitely available to you! You can go to https:\/\/www.meetup.com\/pro\/wordpress\/ to find your local or nearest WordPress meetup group, and if they don't have a workshop on the schedule \u2014 the meetups that have planned these workshops usually hold it once a year \u2014 then I encourage to ask them about organizing one. :)",
            "status": "approved",
            "parent": {
                "ID": 411811,
                "type": "comment",
                "link": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/411811"
            },
            "type": "comment",
            "like_count": 8,
            "i_like": false,
            "meta": {
                "links": {
                    "self": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/411829",
                    "help": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/411829\/help",
                    "site": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907",
                    "post": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/posts\/41513",
                    "replies": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/411829\/replies\/",
                    "likes": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/411829\/likes\/"
                }
            },
            "can_moderate": false
        },
        {
            "ID": 411821,
            "post": {
                "ID": 41513,
                "title": "Want to See a More Diverse WordPress Contributor Community? So Do We.",
                "type": "post",
                "link": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/posts\/41513"
            },
            "author": {
                "ID": 0,
                "login": "",
                "email": false,
                "name": "Mia Winhertt",
                "first_name": "",
                "last_name": "",
                "nice_name": "",
                "URL": "http:\/\/miawinhertt.wordpress.com",
                "avatar_URL": "https:\/\/2.gravatar.com\/avatar\/224a7750861f073d225029ae1e477084?s=96&d=retro",
                "profile_URL": "https:\/\/en.gravatar.com\/224a7750861f073d225029ae1e477084",
                "ip_address": false
            },
            "date": "2019-06-20T07:41:14+00:00",
            "URL": "http:\/\/en.blog.wordpress.com\/2019\/06\/19\/want-to-see-a-more-diverse-wordpress-contributor-community-so-do-we\/#comment-411821",
            "short_URL": "https:\/\/wp.me\/pf2B5-aNz%23comment-411821",
            "content": "<p>The more diverse a project, the better its reach. Kudos to Jill Binder for taking the initiative for a great step forward in this direction. \u263a<\/p>\n",
            "raw_content": "The more diverse a project, the better its reach. Kudos to Jill Binder for taking the initiative for a great step forward in this direction. \u263a",
            "status": "approved",
            "parent": false,
            "type": "comment",
            "like_count": 14,
            "i_like": false,
            "meta": {
                "links": {
                    "self": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/411821",
                    "help": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/411821\/help",
                    "site": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907",
                    "post": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/posts\/41513",
                    "replies": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/411821\/replies\/",
                    "likes": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/411821\/likes\/"
                }
            },
            "can_moderate": false
        }
    ]
}