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": 118639,
    "comments": [
        {
            "ID": 214517,
            "post": {
                "ID": 29255,
                "title": "Explore Longform with Writing 201",
                "type": "post",
                "link": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/posts\/29255"
            },
            "author": {
                "ID": 72950665,
                "login": "kd4cug",
                "email": false,
                "name": "J Alan Clark",
                "nice_name": "kd4cug",
                "URL": "http:\/\/actstwosix.wordpress.com",
                "avatar_URL": "https:\/\/1.gravatar.com\/avatar\/a328a983d6bfa628136904b665567503?s=96&d=retro",
                "profile_URL": "http:\/\/en.gravatar.com\/kd4cug",
                "site_ID": 76387143
            },
            "date": "2014-11-22T11:33:37+00:00",
            "URL": "http:\/\/en.blog.wordpress.com\/2014\/11\/21\/writing-201-longform\/comment-page-1\/#comment-214517",
            "short_URL": "http:\/\/wp.me\/pf2B5-7BR%23comment-214517",
            "content": "<p>Great Idea.<\/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\/214517",
                    "help": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/214517\/help",
                    "site": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907",
                    "post": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/posts\/29255",
                    "replies": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/214517\/replies\/",
                    "likes": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/214517\/likes\/"
                }
            }
        },
        {
            "ID": 214513,
            "post": {
                "ID": 29255,
                "title": "Explore Longform with Writing 201",
                "type": "post",
                "link": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/posts\/29255"
            },
            "author": {
                "ID": 24474157,
                "login": "talesfromthemotherland",
                "email": false,
                "name": "talesfromthemotherland",
                "nice_name": "talesfromthemotherland",
                "URL": "http:\/\/talesfromthemotherland.wordpress.com",
                "avatar_URL": "https:\/\/0.gravatar.com\/avatar\/630643909e2d6502f34c6540d48624f2?s=96&d=retro",
                "profile_URL": "http:\/\/en.gravatar.com\/talesfromthemotherland",
                "site_ID": 24413818
            },
            "date": "2014-11-22T05:50:44+00:00",
            "URL": "http:\/\/en.blog.wordpress.com\/2014\/11\/21\/writing-201-longform\/comment-page-1\/#comment-214513",
            "short_URL": "http:\/\/wp.me\/pf2B5-7BR%23comment-214513",
            "content": "<p>While I&#8217;m buried in writing &#8220;assignments&#8221; right now, Michelle, it&#8217;s exciting to see you covering longform. I submit posts to Longreads on a regular basis; it&#8217;s my niche, for sure. Looking forward to seeing what you do with this!<\/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\/214513",
                    "help": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/214513\/help",
                    "site": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907",
                    "post": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/posts\/29255",
                    "replies": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/214513\/replies\/",
                    "likes": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/214513\/likes\/"
                }
            }
        },
        {
            "ID": 214494,
            "post": {
                "ID": 29255,
                "title": "Explore Longform with Writing 201",
                "type": "post",
                "link": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/posts\/29255"
            },
            "author": {
                "ID": 58764889,
                "login": "creativebynight1",
                "email": false,
                "name": "Little Miss Menopause",
                "nice_name": "creativebynight1",
                "URL": "http:\/\/thequotegal.wordpress.com",
                "avatar_URL": "https:\/\/0.gravatar.com\/avatar\/90b0ca05d097f4906b4506692df35556?s=96&d=retro",
                "profile_URL": "http:\/\/en.gravatar.com\/creativebynight1",
                "site_ID": 61369872
            },
            "date": "2014-11-21T17:27:14+00:00",
            "URL": "http:\/\/en.blog.wordpress.com\/2014\/11\/21\/writing-201-longform\/comment-page-1\/#comment-214494",
            "short_URL": "http:\/\/wp.me\/pf2B5-7BR%23comment-214494",
            "content": "<p>&#8220;&#8230;including the founders and editors at Longreads &#8212; folks who know a thing or two about high word counts.&#8221;<\/p>\n<p>I keep thinking these people should be called &#8220;Longfellows!&#8221;<\/p>\n<p>Sounds like an exciting course.<\/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\/214494",
                    "help": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/214494\/help",
                    "site": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907",
                    "post": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/posts\/29255",
                    "replies": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/214494\/replies\/",
                    "likes": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/214494\/likes\/"
                }
            }
        },
        {
            "ID": 214493,
            "post": {
                "ID": 29255,
                "title": "Explore Longform with Writing 201",
                "type": "post",
                "link": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/posts\/29255"
            },
            "author": {
                "ID": 28495047,
                "login": "mangiachetifabenebimbo",
                "email": false,
                "name": "mangiachetifabenebimbo!",
                "nice_name": "mangiachetifabenebimbo",
                "URL": "http:\/\/mangiachetifabenebimbo.wordpress.com",
                "avatar_URL": "https:\/\/2.gravatar.com\/avatar\/569e8bff7a3f488843ffa15d09905e63?s=96&d=retro",
                "profile_URL": "http:\/\/en.gravatar.com\/mangiachetifabenebimbo",
                "site_ID": 28954068
            },
            "date": "2014-11-21T17:05:03+00:00",
            "URL": "http:\/\/en.blog.wordpress.com\/2014\/11\/21\/writing-201-longform\/comment-page-1\/#comment-214493",
            "short_URL": "http:\/\/wp.me\/pf2B5-7BR%23comment-214493",
            "content": "<p>This is absolutely awesome! thank you guys for such an interesting and helpful idea!<\/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\/214493",
                    "help": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/214493\/help",
                    "site": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907",
                    "post": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/posts\/29255",
                    "replies": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/214493\/replies\/",
                    "likes": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/214493\/likes\/"
                }
            }
        },
        {
            "ID": 214487,
            "post": {
                "ID": 29255,
                "title": "Explore Longform with Writing 201",
                "type": "post",
                "link": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/posts\/29255"
            },
            "author": {
                "ID": 75271543,
                "login": "sislaton",
                "email": false,
                "name": "Songbird Sherrie",
                "nice_name": "sislaton",
                "URL": "http:\/\/songbirdsherrie.wordpress.com",
                "avatar_URL": "https:\/\/0.gravatar.com\/avatar\/ce450a6f8eb8c947a2c4b68946edaf7d?s=96&d=retro",
                "profile_URL": "http:\/\/en.gravatar.com\/sislaton",
                "site_ID": 78919049
            },
            "date": "2014-11-21T16:31:57+00:00",
            "URL": "http:\/\/en.blog.wordpress.com\/2014\/11\/21\/writing-201-longform\/comment-page-1\/#comment-214487",
            "short_URL": "http:\/\/wp.me\/pf2B5-7BR%23comment-214487",
            "content": "<p>I am excited about this! Thank you for your time and education! Embrace your Greatness!<\/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\/214487",
                    "help": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/214487\/help",
                    "site": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907",
                    "post": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/posts\/29255",
                    "replies": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/214487\/replies\/",
                    "likes": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/214487\/likes\/"
                }
            }
        }
    ]
}