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": 118426,
    "comments": [
        {
            "ID": 213874,
            "post": {
                "ID": 29131,
                "title": "Blogging U.&#8217;s Photo 101 Course: Post a Photo a Day",
                "type": "post",
                "link": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/posts\/29131"
            },
            "author": {
                "ID": 10183950,
                "login": "cherilucas",
                "email": false,
                "name": "Cheri Lucas Rowlands",
                "nice_name": "cherilucas",
                "URL": "http:\/\/writingthroughthefog.com",
                "avatar_URL": "https:\/\/0.gravatar.com\/avatar\/36207d4c7c014b0999b995ca3971d383?s=96&d=retro",
                "profile_URL": "http:\/\/en.gravatar.com\/cherilucas",
                "site_ID": 9838404
            },
            "date": "2014-10-30T19:20:21+00:00",
            "URL": "http:\/\/en.blog.wordpress.com\/2014\/10\/28\/photography-101-course\/comment-page-1\/#comment-213874",
            "short_URL": "http:\/\/wp.me\/pf2B5-7zR%23comment-213874",
            "content": "<p>Hi there &#8212; no, as I mentioned in the post, there are no prerequisites.<\/p>\n",
            "status": "approved",
            "parent": {
                "ID": 213869,
                "type": "comment",
                "link": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/213869"
            },
            "type": "comment",
            "like_count": 0,
            "i_like": false,
            "meta": {
                "links": {
                    "self": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/213874",
                    "help": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/213874\/help",
                    "site": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907",
                    "post": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/posts\/29131",
                    "replies": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/213874\/replies\/",
                    "likes": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/213874\/likes\/"
                }
            }
        },
        {
            "ID": 213870,
            "post": {
                "ID": 29079,
                "title": "The NaMos are Coming! The NaMos are Coming!",
                "type": "post",
                "link": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/posts\/29079"
            },
            "author": {
                "ID": 23467831,
                "login": "zjudra",
                "email": false,
                "name": "Cassandra",
                "nice_name": "zjudra",
                "URL": "http:\/\/zjudraadvanced.wordpress.com",
                "avatar_URL": "https:\/\/0.gravatar.com\/avatar\/38bea7e4a4d1272f32327d4396fcf564?s=96&d=retro",
                "profile_URL": "http:\/\/en.gravatar.com\/zjudra",
                "site_ID": 23216852
            },
            "date": "2014-10-30T18:01:20+00:00",
            "URL": "http:\/\/en.blog.wordpress.com\/2014\/10\/24\/the-namos-are-coming-the-namos-are-coming\/comment-page-1\/#comment-213870",
            "short_URL": "http:\/\/wp.me\/pf2B5-7z1%23comment-213870",
            "content": "<p>I&#8217;ve been procrastinating, time to get with it. This will be the boost I needed.<\/p>\n",
            "status": "approved",
            "parent": false,
            "type": "comment",
            "like_count": 0,
            "i_like": false,
            "meta": {
                "links": {
                    "self": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/213870",
                    "help": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/213870\/help",
                    "site": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907",
                    "post": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/posts\/29079",
                    "replies": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/213870\/replies\/",
                    "likes": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/213870\/likes\/"
                }
            }
        },
        {
            "ID": 213869,
            "post": {
                "ID": 29131,
                "title": "Blogging U.&#8217;s Photo 101 Course: Post a Photo a Day",
                "type": "post",
                "link": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/posts\/29131"
            },
            "author": {
                "ID": 54460189,
                "login": "harrimanhooper",
                "email": false,
                "name": "donavon",
                "nice_name": "harrimanhooper",
                "URL": "http:\/\/harrimanhooper.wordpress.com",
                "avatar_URL": "https:\/\/1.gravatar.com\/avatar\/a0c44c03f43ea75c84a03a123efb32a3?s=96&d=retro",
                "profile_URL": "http:\/\/en.gravatar.com\/harrimanhooper",
                "site_ID": 56983076
            },
            "date": "2014-10-30T17:58:29+00:00",
            "URL": "http:\/\/en.blog.wordpress.com\/2014\/10\/28\/photography-101-course\/comment-page-1\/#comment-213869",
            "short_URL": "http:\/\/wp.me\/pf2B5-7zR%23comment-213869",
            "content": "<p>Seems like a pretty cool course &#8211; can&#8217;t wait to try something exciting and new&#8230; Are there stipulations to this course? <\/p>\n",
            "status": "approved",
            "parent": false,
            "type": "comment",
            "like_count": 0,
            "i_like": false,
            "meta": {
                "links": {
                    "self": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/213869",
                    "help": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/213869\/help",
                    "site": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907",
                    "post": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/posts\/29131",
                    "replies": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/213869\/replies\/",
                    "likes": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/213869\/likes\/"
                }
            }
        },
        {
            "ID": 213864,
            "post": {
                "ID": 29131,
                "title": "Blogging U.&#8217;s Photo 101 Course: Post a Photo a Day",
                "type": "post",
                "link": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/posts\/29131"
            },
            "author": {
                "ID": 74287198,
                "login": "mrsmrobinson2014",
                "email": false,
                "name": "mrsmrobinson2014",
                "nice_name": "mrsmrobinson2014",
                "URL": "http:\/\/mrsswedishrobinson.wordpress.com",
                "avatar_URL": "https:\/\/1.gravatar.com\/avatar\/7426d5d5486bcf63f2fe0007e703f1a6?s=96&d=retro",
                "profile_URL": "http:\/\/en.gravatar.com\/mrsmrobinson2014",
                "site_ID": 77843800
            },
            "date": "2014-10-30T15:26:48+00:00",
            "URL": "http:\/\/en.blog.wordpress.com\/2014\/10\/28\/photography-101-course\/comment-page-1\/#comment-213864",
            "short_URL": "http:\/\/wp.me\/pf2B5-7zR%23comment-213864",
            "content": "<p>I&#8217;m okay in taking pics, but I can always improve. Blogging is something new to me,so I&#8217;m curious about about what to learn. <span class='wp-smiley wp-emoji wp-emoji-smile' title=':-)'>:-)<\/span><\/p>\n",
            "status": "approved",
            "parent": false,
            "type": "comment",
            "like_count": 1,
            "i_like": false,
            "meta": {
                "links": {
                    "self": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/213864",
                    "help": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/213864\/help",
                    "site": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907",
                    "post": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/posts\/29131",
                    "replies": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/213864\/replies\/",
                    "likes": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/213864\/likes\/"
                }
            }
        },
        {
            "ID": 213861,
            "post": {
                "ID": 29079,
                "title": "The NaMos are Coming! The NaMos are Coming!",
                "type": "post",
                "link": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/posts\/29079"
            },
            "author": {
                "ID": 40853890,
                "login": "psub06",
                "email": false,
                "name": "funky_sheep",
                "nice_name": "psub06",
                "URL": "https:\/\/maponmyheart.wordpress.com\/",
                "avatar_URL": "https:\/\/2.gravatar.com\/avatar\/8b4bb448e631236b83247752a35bae5c?s=96&d=retro",
                "profile_URL": "http:\/\/en.gravatar.com\/psub06",
                "site_ID": 55685528
            },
            "date": "2014-10-30T13:38:34+00:00",
            "URL": "http:\/\/en.blog.wordpress.com\/2014\/10\/24\/the-namos-are-coming-the-namos-are-coming\/comment-page-1\/#comment-213861",
            "short_URL": "http:\/\/wp.me\/pf2B5-7z1%23comment-213861",
            "content": "<p>I loved this post, I&#8217;d never heard on NaBloPoMo (hehehe, that name still makes me giggle&#8230;) before, and this has inspired me to give it a go! Let&#8217;s see how far I get&#8230;<\/p>\n",
            "status": "approved",
            "parent": false,
            "type": "comment",
            "like_count": 0,
            "i_like": false,
            "meta": {
                "links": {
                    "self": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/213861",
                    "help": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/213861\/help",
                    "site": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907",
                    "post": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/posts\/29079",
                    "replies": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/213861\/replies\/",
                    "likes": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/213861\/likes\/"
                }
            }
        }
    ]
}