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": 114588,
    "comments": [
        {
            "ID": 202746,
            "post": {
                "ID": 26558,
                "type": "post",
                "link": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/posts\/26558"
            },
            "author": {
                "ID": 47411601,
                "email": false,
                "name": "Ben Huberman",
                "nice_name": "benhuberman",
                "URL": "",
                "avatar_URL": "https:\/\/0.gravatar.com\/avatar\/663dcd498e8c5f255bfb230a7ba07678?s=96&d=retro",
                "profile_URL": "http:\/\/en.gravatar.com\/benhuberman",
                "site_ID": 48638359
            },
            "date": "2014-04-24T06:49:20+00:00",
            "URL": "http:\/\/en.blog.wordpress.com\/2014\/04\/23\/building-poetry-communities\/comment-page-1\/#comment-202746",
            "short_URL": "http:\/\/wp.me\/pf2B5-6Um%23comment-202746",
            "content": "<p>I think the best thing for you would be to make contact with those poets you encounter whose work resonates with yours: you could then guest-blog on each other&#8217;s sites, share each other&#8217;s work, and even start a group blog if you feel so inclined. You could also try to have a group of like-minded poets to use a tag like &#8220;photo-poem&#8221; in your posts so that it&#8217;s easy for everyone to find this type of poetry in the Reader.<\/p>\n",
            "status": "approved",
            "parent": {
                "ID": 202711,
                "type": "comment",
                "link": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/202711"
            },
            "type": "comment",
            "meta": {
                "links": {
                    "self": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/202746",
                    "help": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/202746\/help",
                    "site": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907",
                    "post": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/posts\/26558",
                    "replies": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/202746\/replies\/"
                }
            }
        },
        {
            "ID": 202739,
            "post": {
                "ID": 26533,
                "type": "post",
                "link": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/posts\/26533"
            },
            "author": {
                "ID": 6714693,
                "email": false,
                "name": "Viesturs",
                "nice_name": "wieshka",
                "URL": "",
                "avatar_URL": "https:\/\/1.gravatar.com\/avatar\/42f7322b24ae2e096cf1de05be6ae744?s=96&d=retro",
                "profile_URL": "http:\/\/en.gravatar.com\/wieshka",
                "site_ID": 62263481
            },
            "date": "2014-04-24T04:04:09+00:00",
            "URL": "http:\/\/en.blog.wordpress.com\/2014\/04\/23\/early-theme-adopters-hemingway-rewritten\/comment-page-1\/#comment-202739",
            "short_URL": "http:\/\/wp.me\/pf2B5-6TX%23comment-202739",
            "content": "<p>Thanks for such a great theme &#8211; finally reanimated my blog and started from a blank page.<\/p>\n",
            "status": "approved",
            "parent": false,
            "type": "comment",
            "meta": {
                "links": {
                    "self": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/202739",
                    "help": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/202739\/help",
                    "site": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907",
                    "post": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/posts\/26533",
                    "replies": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/202739\/replies\/"
                }
            }
        },
        {
            "ID": 202735,
            "post": {
                "ID": 26558,
                "type": "post",
                "link": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/posts\/26558"
            },
            "author": {
                "ID": 61058341,
                "email": false,
                "name": "Louise B. Leger",
                "nice_name": "louisebleger",
                "URL": "http:\/\/louisebleger.wordpress.com",
                "avatar_URL": "https:\/\/0.gravatar.com\/avatar\/03b38e87e145b60400ac41e56005d7e5?s=96&d=retro",
                "profile_URL": "http:\/\/en.gravatar.com\/louisebleger",
                "site_ID": 63816224
            },
            "date": "2014-04-24T02:11:38+00:00",
            "URL": "http:\/\/en.blog.wordpress.com\/2014\/04\/23\/building-poetry-communities\/comment-page-1\/#comment-202735",
            "short_URL": "http:\/\/wp.me\/pf2B5-6Um%23comment-202735",
            "content": "<p>This is what my blog is all about. Although none of these communities seem to fit me. Anyone looking for some friends on here who are also interested in poetry feel free to get at me ! <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\/202735",
                    "help": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/202735\/help",
                    "site": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907",
                    "post": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/posts\/26558",
                    "replies": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/202735\/replies\/"
                }
            }
        },
        {
            "ID": 202731,
            "post": {
                "ID": 26558,
                "type": "post",
                "link": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/posts\/26558"
            },
            "author": {
                "ID": 28044291,
                "email": false,
                "name": "y. prior",
                "nice_name": "mrsprior",
                "URL": "http:\/\/priorhouse.wordpress.com",
                "avatar_URL": "https:\/\/1.gravatar.com\/avatar\/d5808710e1489c8a537d8d2b062447e4?s=96&d=retro",
                "profile_URL": "http:\/\/en.gravatar.com\/mrsprior",
                "site_ID": 28505188
            },
            "date": "2014-04-24T00:59:06+00:00",
            "URL": "http:\/\/en.blog.wordpress.com\/2014\/04\/23\/building-poetry-communities\/comment-page-1\/#comment-202731",
            "short_URL": "http:\/\/wp.me\/pf2B5-6Um%23comment-202731",
            "content": "<p>Interesting post!  And loved this:  &#8220;but it\u2019s only when we join a community of other writers and readers that our voices are truly heard.&#8221;<\/p>\n<p>Well said, well said\u2026..<\/p>\n",
            "status": "approved",
            "parent": false,
            "type": "comment",
            "meta": {
                "links": {
                    "self": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/202731",
                    "help": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/202731\/help",
                    "site": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907",
                    "post": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/posts\/26558",
                    "replies": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/202731\/replies\/"
                }
            }
        },
        {
            "ID": 202728,
            "post": {
                "ID": 26533,
                "type": "post",
                "link": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/posts\/26533"
            },
            "author": {
                "ID": 62044659,
                "email": false,
                "name": "Kimbery Camp",
                "nice_name": "campke",
                "URL": "http:\/\/couldyoudietforme.wordpress.com",
                "avatar_URL": "https:\/\/0.gravatar.com\/avatar\/957e2a010f3511c2d8960888464414d0?s=96&d=retro",
                "profile_URL": "http:\/\/en.gravatar.com\/campke",
                "site_ID": 64852314
            },
            "date": "2014-04-24T00:41:10+00:00",
            "URL": "http:\/\/en.blog.wordpress.com\/2014\/04\/23\/early-theme-adopters-hemingway-rewritten\/comment-page-1\/#comment-202728",
            "short_URL": "http:\/\/wp.me\/pf2B5-6TX%23comment-202728",
            "content": "<p>Wow. I&#8217;m also new to WordPress; I picked the theme because it looked closest to what was in my head. Can&#8217;t wait to have time to tinker with the features. <\/p>\n",
            "status": "approved",
            "parent": false,
            "type": "comment",
            "meta": {
                "links": {
                    "self": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/202728",
                    "help": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/202728\/help",
                    "site": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907",
                    "post": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/posts\/26533",
                    "replies": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/202728\/replies\/"
                }
            }
        }
    ]
}