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
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).
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": 117175,
    "comments": [
        {
            "ID": 210776,
            "post": {
                "ID": 28411,
                "title": "New Theme: Goran",
                "type": "post",
                "link": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/posts\/28411"
            },
            "author": {
                "ID": 63944103,
                "login": "tanmaysetia",
                "email": false,
                "name": "tanmaysetia",
                "nice_name": "tanmaysetia",
                "URL": "http:\/\/setiatanmay.wordpress.com",
                "avatar_URL": "https:\/\/1.gravatar.com\/avatar\/44fcc107726c31d285f11beb500abe0e?s=96&d=retro",
                "profile_URL": "http:\/\/en.gravatar.com\/tanmaysetia",
                "site_ID": 66828623
            },
            "date": "2014-08-31T16:02:25+00:00",
            "URL": "http:\/\/en.blog.wordpress.com\/2014\/08\/28\/goran\/comment-page-1\/#comment-210776",
            "short_URL": "http:\/\/wp.me\/sf2B5-goran%23comment-210776",
            "content": "<p>this theme looks great!<\/p>\n",
            "status": "approved",
            "parent": false,
            "type": "comment",
            "meta": {
                "links": {
                    "self": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/210776",
                    "help": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/210776\/help",
                    "site": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907",
                    "post": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/posts\/28411",
                    "replies": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/210776\/replies\/",
                    "likes": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/210776\/likes\/"
                }
            }
        },
        {
            "ID": 210775,
            "post": {
                "ID": 28303,
                "title": "Projects Around the World",
                "type": "post",
                "link": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/posts\/28303"
            },
            "author": {
                "ID": 60505222,
                "login": "goutamvenkatesh",
                "email": false,
                "name": "Goutam Venkatesh",
                "nice_name": "goutamvenkatesh",
                "URL": "http:\/\/goutamvenkatesh.wordpress.com",
                "avatar_URL": "https:\/\/1.gravatar.com\/avatar\/add8830697928c69c609168e408e1954?s=96&d=retro",
                "profile_URL": "http:\/\/en.gravatar.com\/goutamvenkatesh",
                "site_ID": 63224439
            },
            "date": "2014-08-31T15:41:36+00:00",
            "URL": "http:\/\/en.blog.wordpress.com\/2014\/08\/26\/projects-around-the-world\/comment-page-1\/#comment-210775",
            "short_URL": "http:\/\/wp.me\/pf2B5-7mv%23comment-210775",
            "content": "<p>WordPress is a platform, but there were people doing what they&#8217;re doing long before this became popular. More important than wordpress becoming a platform, I think I should commend the hard-working individual\/groups. THEN comes the platform; i congratulate wordpress for this <span class='wp-smiley emoji emoji-smile' title=':)'>:)<\/span><\/p>\n",
            "status": "approved",
            "parent": false,
            "type": "comment",
            "meta": {
                "links": {
                    "self": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/210775",
                    "help": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/210775\/help",
                    "site": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907",
                    "post": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/posts\/28303",
                    "replies": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/210775\/replies\/",
                    "likes": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/210775\/likes\/"
                }
            }
        },
        {
            "ID": 210772,
            "post": {
                "ID": 28411,
                "title": "New Theme: Goran",
                "type": "post",
                "link": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/posts\/28411"
            },
            "author": {
                "ID": 14818610,
                "login": "thomasguillot",
                "email": false,
                "name": "Thomas Guillot",
                "nice_name": "thomasguillot",
                "URL": "http:\/\/www.thomasguillot.com",
                "avatar_URL": "https:\/\/2.gravatar.com\/avatar\/edda6f87ac9aec0c8464e1b2f1298790?s=96&d=retro",
                "profile_URL": "http:\/\/en.gravatar.com\/thomasguillot",
                "site_ID": 14357053
            },
            "date": "2014-08-31T11:14:07+00:00",
            "URL": "http:\/\/en.blog.wordpress.com\/2014\/08\/28\/goran\/comment-page-1\/#comment-210772",
            "short_URL": "http:\/\/wp.me\/sf2B5-goran%23comment-210772",
            "content": "<blockquote><p>Or does WP.com have a way of smushing images for headers?<\/p><\/blockquote>\n<p>Not just images for headers <span class='wp-smiley emoji emoji-smile' title=':)'>:)<\/span><\/p>\n",
            "status": "approved",
            "parent": {
                "ID": 210741,
                "type": "comment",
                "link": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/210741"
            },
            "type": "comment",
            "meta": {
                "links": {
                    "self": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/210772",
                    "help": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/210772\/help",
                    "site": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907",
                    "post": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/posts\/28411",
                    "replies": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/210772\/replies\/",
                    "likes": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/210772\/likes\/"
                }
            }
        },
        {
            "ID": 210771,
            "post": {
                "ID": 28411,
                "title": "New Theme: Goran",
                "type": "post",
                "link": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/posts\/28411"
            },
            "author": {
                "ID": 14818610,
                "login": "thomasguillot",
                "email": false,
                "name": "Thomas Guillot",
                "nice_name": "thomasguillot",
                "URL": "http:\/\/www.thomasguillot.com",
                "avatar_URL": "https:\/\/2.gravatar.com\/avatar\/edda6f87ac9aec0c8464e1b2f1298790?s=96&d=retro",
                "profile_URL": "http:\/\/en.gravatar.com\/thomasguillot",
                "site_ID": 14357053
            },
            "date": "2014-08-31T11:10:37+00:00",
            "URL": "http:\/\/en.blog.wordpress.com\/2014\/08\/28\/goran\/comment-page-1\/#comment-210771",
            "short_URL": "http:\/\/wp.me\/sf2B5-goran%23comment-210771",
            "content": "<p>The theme&#8217;s documentation is available <a href=\"http:\/\/theme.wordpress.com\/themes\/goran\/\" rel=\"nofollow\">here<\/a>. Hope it helps! <span class='wp-smiley emoji emoji-smile' title=':)'>:)<\/span><\/p>\n",
            "status": "approved",
            "parent": {
                "ID": 210762,
                "type": "comment",
                "link": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/210762"
            },
            "type": "comment",
            "meta": {
                "links": {
                    "self": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/210771",
                    "help": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/210771\/help",
                    "site": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907",
                    "post": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/posts\/28411",
                    "replies": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/210771\/replies\/",
                    "likes": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/210771\/likes\/"
                }
            }
        },
        {
            "ID": 210767,
            "post": {
                "ID": 28411,
                "title": "New Theme: Goran",
                "type": "post",
                "link": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/posts\/28411"
            },
            "author": {
                "ID": 68438713,
                "login": "elzeroapparel",
                "email": false,
                "name": "Elzero Apparel",
                "nice_name": "elzeroapparel",
                "URL": "http:\/\/elzeroapparel.wordpress.com",
                "avatar_URL": "https:\/\/0.gravatar.com\/avatar\/3eba8afa71da2187b8ed00f86d1cf269?s=96&d=retro",
                "profile_URL": "http:\/\/en.gravatar.com\/elzeroapparel",
                "site_ID": 71553817
            },
            "date": "2014-08-31T03:04:32+00:00",
            "URL": "http:\/\/en.blog.wordpress.com\/2014\/08\/28\/goran\/comment-page-1\/#comment-210767",
            "short_URL": "http:\/\/wp.me\/sf2B5-goran%23comment-210767",
            "content": "<p>amazing!! <span class='wp-smiley emoji emoji-bigsmile' title=':D'>:D<\/span><\/p>\n",
            "status": "approved",
            "parent": false,
            "type": "comment",
            "meta": {
                "links": {
                    "self": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/210767",
                    "help": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/210767\/help",
                    "site": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907",
                    "post": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/posts\/28411",
                    "replies": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/210767\/replies\/",
                    "likes": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/210767\/likes\/"
                }
            }
        }
    ]
}