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": 117653,
    "comments": [
        {
            "ID": 212207,
            "post": {
                "ID": 28737,
                "title": "Engaged, Inspired, and Ready to Build a Better Web",
                "type": "post",
                "link": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/posts\/28737"
            },
            "author": {
                "ID": 2193192,
                "login": "michelleweber",
                "email": false,
                "name": "Michelle W.",
                "nice_name": "michelleweber",
                "URL": "http:\/\/kingofstates.com",
                "avatar_URL": "https:\/\/2.gravatar.com\/avatar\/2367004060918e221dcb9799584e9279?s=96&d=retro",
                "profile_URL": "http:\/\/en.gravatar.com\/michelleweber",
                "site_ID": 40536446
            },
            "date": "2014-09-30T20:12:10+00:00",
            "URL": "http:\/\/en.blog.wordpress.com\/2014\/09\/30\/grand-meetup-reflections\/comment-page-1\/#comment-212207",
            "short_URL": "http:\/\/wp.me\/pf2B5-7tv%23comment-212207",
            "content": "<p>I believe there was some Dominion action as well, along with more party-style board games like Cranium. (Not that I mean to suggest that Settlers of Catan is not a non-stop party.)<\/p>\n",
            "status": "approved",
            "parent": {
                "ID": 212201,
                "type": "comment",
                "link": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/212201"
            },
            "type": "comment",
            "meta": {
                "links": {
                    "self": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/212207",
                    "help": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/212207\/help",
                    "site": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907",
                    "post": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/posts\/28737",
                    "replies": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/212207\/replies\/",
                    "likes": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/212207\/likes\/"
                }
            }
        },
        {
            "ID": 212206,
            "post": {
                "ID": 28737,
                "title": "Engaged, Inspired, and Ready to Build a Better Web",
                "type": "post",
                "link": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/posts\/28737"
            },
            "author": {
                "ID": 2193192,
                "login": "michelleweber",
                "email": false,
                "name": "Michelle W.",
                "nice_name": "michelleweber",
                "URL": "http:\/\/kingofstates.com",
                "avatar_URL": "https:\/\/2.gravatar.com\/avatar\/2367004060918e221dcb9799584e9279?s=96&d=retro",
                "profile_URL": "http:\/\/en.gravatar.com\/michelleweber",
                "site_ID": 40536446
            },
            "date": "2014-09-30T20:11:06+00:00",
            "URL": "http:\/\/en.blog.wordpress.com\/2014\/09\/30\/grand-meetup-reflections\/comment-page-1\/#comment-212206",
            "short_URL": "http:\/\/wp.me\/pf2B5-7tv%23comment-212206",
            "content": "<p>Thanks! And thanks to all of you for doing such awesome things with the stuff we make <span class='wp-smiley emoji emoji-smile' title=':)'>:)<\/span><\/p>\n",
            "status": "approved",
            "parent": {
                "ID": 212202,
                "type": "comment",
                "link": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/212202"
            },
            "type": "comment",
            "meta": {
                "links": {
                    "self": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/212206",
                    "help": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/212206\/help",
                    "site": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907",
                    "post": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/posts\/28737",
                    "replies": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/212206\/replies\/",
                    "likes": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/212206\/likes\/"
                }
            }
        },
        {
            "ID": 212205,
            "post": {
                "ID": 28737,
                "title": "Engaged, Inspired, and Ready to Build a Better Web",
                "type": "post",
                "link": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/posts\/28737"
            },
            "author": {
                "ID": 53844793,
                "login": "tominalbion",
                "email": false,
                "name": "tominalbion",
                "nice_name": "tominalbion",
                "URL": "http:\/\/albiontoamerica.wordpress.com",
                "avatar_URL": "https:\/\/0.gravatar.com\/avatar\/cd0b957807b9d859b62f0fe2cf6a2c04?s=96&d=retro",
                "profile_URL": "http:\/\/en.gravatar.com\/tominalbion",
                "site_ID": 63670620
            },
            "date": "2014-09-30T20:03:50+00:00",
            "URL": "http:\/\/en.blog.wordpress.com\/2014\/09\/30\/grand-meetup-reflections\/comment-page-1\/#comment-212205",
            "short_URL": "http:\/\/wp.me\/pf2B5-7tv%23comment-212205",
            "content": "<p>Very interesting, will be checking out those vacancies as it looks like a fun place to work!<\/p>\n",
            "status": "approved",
            "parent": false,
            "type": "comment",
            "meta": {
                "links": {
                    "self": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/212205",
                    "help": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/212205\/help",
                    "site": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907",
                    "post": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/posts\/28737",
                    "replies": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/212205\/replies\/",
                    "likes": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/212205\/likes\/"
                }
            }
        },
        {
            "ID": 212204,
            "post": {
                "ID": 28737,
                "title": "Engaged, Inspired, and Ready to Build a Better Web",
                "type": "post",
                "link": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/posts\/28737"
            },
            "author": {
                "ID": 11608966,
                "login": "annestormont",
                "email": false,
                "name": "writeanne",
                "nice_name": "annestormont",
                "URL": "http:\/\/annestormont.wordpress.com",
                "avatar_URL": "https:\/\/1.gravatar.com\/avatar\/4f3caca75466e9da8f9f9dfc1e04ab48?s=96&d=retro",
                "profile_URL": "http:\/\/en.gravatar.com\/annestormont",
                "site_ID": 11300157
            },
            "date": "2014-09-30T20:03:38+00:00",
            "URL": "http:\/\/en.blog.wordpress.com\/2014\/09\/30\/grand-meetup-reflections\/comment-page-1\/#comment-212204",
            "short_URL": "http:\/\/wp.me\/pf2B5-7tv%23comment-212204",
            "content": "<p>Wow! Just that. Wow! Here&#8217;s to another great year for you all. Slainte mhath (cheers). Love that Scottish Independence was on the chat list <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\/212204",
                    "help": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/212204\/help",
                    "site": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907",
                    "post": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/posts\/28737",
                    "replies": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/212204\/replies\/",
                    "likes": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/212204\/likes\/"
                }
            }
        },
        {
            "ID": 212202,
            "post": {
                "ID": 28737,
                "title": "Engaged, Inspired, and Ready to Build a Better Web",
                "type": "post",
                "link": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/posts\/28737"
            },
            "author": {
                "ID": 52257885,
                "login": "vakunzmann",
                "email": false,
                "name": "vakunzmann",
                "nice_name": "vakunzmann",
                "URL": "http:\/\/vakunzmann.wordpress.com",
                "avatar_URL": "https:\/\/0.gravatar.com\/avatar\/34110de1f0f0e6453a6b9db742927d97?s=96&d=retro",
                "profile_URL": "http:\/\/en.gravatar.com\/vakunzmann",
                "site_ID": 54660232
            },
            "date": "2014-09-30T19:39:36+00:00",
            "URL": "http:\/\/en.blog.wordpress.com\/2014\/09\/30\/grand-meetup-reflections\/comment-page-1\/#comment-212202",
            "short_URL": "http:\/\/wp.me\/pf2B5-7tv%23comment-212202",
            "content": "<p>Great post!  Looks like you all had a blast.  Thank you for all you do&#8230;each and every one of you.<br \/>\n~victoria<\/p>\n",
            "status": "approved",
            "parent": false,
            "type": "comment",
            "meta": {
                "links": {
                    "self": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/212202",
                    "help": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/212202\/help",
                    "site": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907",
                    "post": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/posts\/28737",
                    "replies": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/212202\/replies\/",
                    "likes": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/212202\/likes\/"
                }
            }
        }
    ]
}