GET /sites/$site/comments/

Return recent Comments

Resource URL

Type URL and Format
GET https://public-api.wordpress.com/rest/v1/sites/$site/comments/

Method Parameters

Parameter Type Description
$site (int|string) The site ID, The site 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
callback (string) An optional JSONP callback function.
number (int) The number of comments to return. Limit: 100. Default: 20.
offset (int) 0-indexed offset.
page (int) Return the Nth 1-indexed page of comments. Takes precedence over the offset parameter.
order (string)
DESC:
(default) Return comments in descending order from newest to oldest.
ASC:
Return comments in ascending order from oldest to newest.
after (iso 8601 datetime) Return comments dated on or after the specified datetime.
before (iso 8601 datetime) Return comments dated on or before the specified datetime.
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).
comments (array) An array of comment objects.

Example

cURL

curl 'https://public-api.wordpress.com/rest/v1/sites/en.blog.wordpress.com/comments/?number=5&pretty=1'

PHP

<?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=5&pretty=1',
  false,
  $context
);
$response = json_decode( $response );

?>

Response Body

{
    "found": 114387,
    "comments": [
        {
            "ID": 202033,
            "post": {
                "ID": 26428,
                "type": "post",
                "link": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/posts\/26428"
            },
            "author": {
                "ID": 43611189,
                "email": false,
                "name": "onnovocks",
                "nice_name": "onnovocks",
                "URL": "http:\/\/onnovocks.wordpress.com",
                "avatar_URL": "https:\/\/0.gravatar.com\/avatar\/6ce31bcd9b15f2b991c3f6c990910b93?s=96&d=retro",
                "profile_URL": "http:\/\/en.gravatar.com\/onnovocks",
                "site_ID": 44228134
            },
            "date": "2014-04-18T19:16:40+00:00",
            "URL": "http:\/\/en.blog.wordpress.com\/2014\/04\/17\/transparency-report\/comment-page-1\/#comment-202033",
            "short_URL": "http:\/\/wp.me\/pf2B5-6Sg%23comment-202033",
            "content": "<p>Thanks for trying, thumbs up!<\/p>\n",
            "status": "approved",
            "parent": false,
            "type": "comment",
            "meta": {
                "links": {
                    "self": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/202033",
                    "help": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/202033\/help",
                    "site": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907",
                    "post": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/posts\/26428",
                    "replies": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/202033\/replies\/"
                }
            }
        },
        {
            "ID": 202028,
            "post": {
                "ID": 26382,
                "type": "post",
                "link": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/posts\/26382"
            },
            "author": {
                "ID": 64340458,
                "email": false,
                "name": "shavonmenne",
                "nice_name": "shavonmenne",
                "URL": "http:\/\/shavonmenne.wordpress.com",
                "avatar_URL": "https:\/\/2.gravatar.com\/avatar\/52dabbf9ec2edbec3894ec59a2e282b3?s=96&d=retro",
                "profile_URL": "http:\/\/en.gravatar.com\/shavonmenne",
                "site_ID": 67252118
            },
            "date": "2014-04-18T18:26:50+00:00",
            "URL": "http:\/\/en.blog.wordpress.com\/2014\/04\/18\/three-features-to-dig\/comment-page-1\/#comment-202028",
            "short_URL": "http:\/\/wp.me\/pf2B5-6Rw%23comment-202028",
            "content": "<p>Hey this is going to help me a lot. I can&#8217;t wait to get started.<\/p>\n",
            "status": "approved",
            "parent": false,
            "type": "comment",
            "meta": {
                "links": {
                    "self": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/202028",
                    "help": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/202028\/help",
                    "site": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907",
                    "post": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/posts\/26382",
                    "replies": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/202028\/replies\/"
                }
            }
        },
        {
            "ID": 202026,
            "post": {
                "ID": 26382,
                "type": "post",
                "link": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/posts\/26382"
            },
            "author": {
                "ID": 484358,
                "email": false,
                "name": "Sunite",
                "nice_name": "sunite",
                "URL": "http:\/\/dailyanimeart.com",
                "avatar_URL": "https:\/\/0.gravatar.com\/avatar\/348dc87049389391a4ad8c6eefddd85e?s=96&d=retro",
                "profile_URL": "http:\/\/en.gravatar.com\/sunite",
                "site_ID": 19786462
            },
            "date": "2014-04-18T17:58:12+00:00",
            "URL": "http:\/\/en.blog.wordpress.com\/2014\/04\/18\/three-features-to-dig\/comment-page-1\/#comment-202026",
            "short_URL": "http:\/\/wp.me\/pf2B5-6Rw%23comment-202026",
            "content": "<p>Thank you for these tips, I will be sure to use them. Especially the scheduling feature.<\/p>\n",
            "status": "approved",
            "parent": false,
            "type": "comment",
            "meta": {
                "links": {
                    "self": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/202026",
                    "help": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/202026\/help",
                    "site": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907",
                    "post": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/posts\/26382",
                    "replies": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/202026\/replies\/"
                }
            }
        },
        {
            "ID": 202024,
            "post": {
                "ID": 26382,
                "type": "post",
                "link": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/posts\/26382"
            },
            "author": {
                "ID": 59351224,
                "email": false,
                "name": "barn7777",
                "nice_name": "barn7777",
                "URL": "http:\/\/barn7777.wordpress.com",
                "avatar_URL": "https:\/\/0.gravatar.com\/avatar\/61cffa913773c89510262c9fa40b15a0?s=96&d=retro",
                "profile_URL": "http:\/\/en.gravatar.com\/barn7777",
                "site_ID": 62112416
            },
            "date": "2014-04-18T17:44:15+00:00",
            "URL": "http:\/\/en.blog.wordpress.com\/2014\/04\/18\/three-features-to-dig\/comment-page-1\/#comment-202024",
            "short_URL": "http:\/\/wp.me\/pf2B5-6Rw%23comment-202024",
            "content": "<p>Extremely helpful for those of us (myself included) who are new to blogging with WordPress. I didn&#8217;t even think about the comment prompts&#8211;I will be updating mine!<\/p>\n",
            "status": "approved",
            "parent": false,
            "type": "comment",
            "meta": {
                "links": {
                    "self": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/202024",
                    "help": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/202024\/help",
                    "site": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907",
                    "post": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/posts\/26382",
                    "replies": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/202024\/replies\/"
                }
            }
        },
        {
            "ID": 202023,
            "post": {
                "ID": 26382,
                "type": "post",
                "link": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/posts\/26382"
            },
            "author": {
                "ID": 37633654,
                "email": false,
                "name": "Darshan Gajara",
                "nice_name": "darshangajara",
                "URL": "http:\/\/darshangajara.wordpress.com",
                "avatar_URL": "https:\/\/2.gravatar.com\/avatar\/2a6641306a42d710868fd07ef873bd40?s=96&d=retro",
                "profile_URL": "http:\/\/en.gravatar.com\/darshangajara",
                "site_ID": 38151535
            },
            "date": "2014-04-18T17:41:10+00:00",
            "URL": "http:\/\/en.blog.wordpress.com\/2014\/04\/18\/three-features-to-dig\/comment-page-1\/#comment-202023",
            "short_URL": "http:\/\/wp.me\/pf2B5-6Rw%23comment-202023",
            "content": "<p>This feature is really very efficient. Helps in keeping one&#8217;s Blog active.<\/p>\n",
            "status": "approved",
            "parent": false,
            "type": "comment",
            "meta": {
                "links": {
                    "self": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/202023",
                    "help": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/202023\/help",
                    "site": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907",
                    "post": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/posts\/26382",
                    "replies": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/202023\/replies\/"
                }
            }
        }
    ]
}