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 enviroments (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
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.

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": 105954,
    "comments": [
        {
            "ID": 176775,
            "post": {
                "ID": 17217,
                "type": "post",
                "link": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/posts\/17217"
            },
            "author": {
                "ID": 14313170,
                "email": false,
                "name": "colonialist",
                "URL": "http:\/\/colonialist.wordpress.com",
                "avatar_URL": "http:\/\/2.gravatar.com\/avatar\/26e6cebf3a78e3f4f59074d693c0bdcd?s=96&d=retro",
                "profile_URL": "http:\/\/en.gravatar.com\/colonialist"
            },
            "date": "2013-05-22T20:03:56+00:00",
            "URL": "http:\/\/en.blog.wordpress.com\/2013\/05\/22\/profile-brian-castner\/comment-page-1\/#comment-176775",
            "short_URL": "http:\/\/wp.me\/pf2B5-4tH%23comment-176775",
            "content": "<p>The stress factor in that sort of job must be overwhelming.  It is heartening that writing has enabled you to heal as well as finding a niche.<\/p>\n",
            "status": "approved",
            "parent": false,
            "type": "comment",
            "meta": {
                "links": {
                    "self": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/176775",
                    "help": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/176775\/help",
                    "site": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907",
                    "post": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/posts\/17217",
                    "replies": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/176775\/replies\/"
                }
            }
        },
        {
            "ID": 176770,
            "post": {
                "ID": 17217,
                "type": "post",
                "link": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/posts\/17217"
            },
            "author": {
                "ID": 24583804,
                "email": false,
                "name": "paywindow7",
                "URL": "http:\/\/paywindow7.wordpress.com",
                "avatar_URL": "http:\/\/1.gravatar.com\/avatar\/4718b2e94d987cf012272cc4ec820b25?s=96&d=retro",
                "profile_URL": "http:\/\/en.gravatar.com\/paywindow7"
            },
            "date": "2013-05-22T18:27:23+00:00",
            "URL": "http:\/\/en.blog.wordpress.com\/2013\/05\/22\/profile-brian-castner\/comment-page-1\/#comment-176770",
            "short_URL": "http:\/\/wp.me\/pf2B5-4tH%23comment-176770",
            "content": "<p>First and foremost I want to thank you for your service. I&#8217;m ex-Navy airborne from way back in another time and I&#8217;m looking forward to tracking your blog.<\/p>\n",
            "status": "approved",
            "parent": false,
            "type": "comment",
            "meta": {
                "links": {
                    "self": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/176770",
                    "help": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/176770\/help",
                    "site": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907",
                    "post": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/posts\/17217",
                    "replies": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/176770\/replies\/"
                }
            }
        },
        {
            "ID": 176764,
            "post": {
                "ID": 17217,
                "type": "post",
                "link": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/posts\/17217"
            },
            "author": {
                "ID": 7766734,
                "email": false,
                "name": "Janie Reinart",
                "URL": "",
                "avatar_URL": "http:\/\/2.gravatar.com\/avatar\/8e8688ddf57c0c20acf74bf546e9ccb3?s=96&d=retro",
                "profile_URL": "http:\/\/en.gravatar.com\/janiereinart"
            },
            "date": "2013-05-22T17:15:05+00:00",
            "URL": "http:\/\/en.blog.wordpress.com\/2013\/05\/22\/profile-brian-castner\/comment-page-1\/#comment-176764",
            "short_URL": "http:\/\/wp.me\/pf2B5-4tH%23comment-176764",
            "content": "<p>Brian thank you so much for your service. I am the mom of a veteran. Not only is your blog healing for you, sharing your experiences will help other veterans know that they are not alone. Keep up the good work. Much success with all your writing endeavors.<\/p>\n",
            "status": "approved",
            "parent": false,
            "type": "comment",
            "meta": {
                "links": {
                    "self": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/176764",
                    "help": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/176764\/help",
                    "site": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907",
                    "post": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/posts\/17217",
                    "replies": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/176764\/replies\/"
                }
            }
        },
        {
            "ID": 176760,
            "post": {
                "ID": 17147,
                "type": "post",
                "link": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/posts\/17147"
            },
            "author": {
                "ID": 10406124,
                "email": false,
                "name": "Karen",
                "URL": "http:\/\/thesixtrees.com",
                "avatar_URL": "http:\/\/0.gravatar.com\/avatar\/0fdafe972ad332b313d07e197d1e8b7e?s=96&d=retro",
                "profile_URL": "http:\/\/en.gravatar.com\/kakuii"
            },
            "date": "2013-05-22T15:08:03+00:00",
            "URL": "http:\/\/en.blog.wordpress.com\/2013\/05\/17\/freshly-pressed-faves-8\/comment-page-1\/#comment-176760",
            "short_URL": "http:\/\/wp.me\/pf2B5-4sz%23comment-176760",
            "content": "<p>This is the first time I&#8217;ve ever checked the Freshly Pressed Faves, and what a treat! Thank you for finding some wonderful reading for my morning. Every one of these blogposts is beautiful.<\/p>\n",
            "status": "approved",
            "parent": false,
            "type": "comment",
            "meta": {
                "links": {
                    "self": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/176760",
                    "help": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/176760\/help",
                    "site": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907",
                    "post": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/posts\/17147",
                    "replies": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/176760\/replies\/"
                }
            }
        },
        {
            "ID": 176758,
            "post": {
                "ID": 17157,
                "type": "post",
                "link": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/posts\/17157"
            },
            "author": {
                "ID": 30270631,
                "email": false,
                "name": "Faradiba Achmadi",
                "URL": "http:\/\/foxydiba.wordpress.com",
                "avatar_URL": "http:\/\/0.gravatar.com\/avatar\/c5fdcaaa1bf59357fd05c5d191725f16?s=96&d=retro",
                "profile_URL": "http:\/\/en.gravatar.com\/foxydiba"
            },
            "date": "2013-05-22T13:14:05+00:00",
            "URL": "http:\/\/en.blog.wordpress.com\/2013\/05\/16\/new-theme-snap\/comment-page-1\/#comment-176758",
            "short_URL": "http:\/\/wp.me\/pf2B5-4sJ%23comment-176758",
            "content": "<p>It looks good, really lightweight, another great theme from The Theme Foundry.<\/p>\n",
            "status": "approved",
            "parent": false,
            "type": "comment",
            "meta": {
                "links": {
                    "self": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/176758",
                    "help": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/176758\/help",
                    "site": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907",
                    "post": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/posts\/17157",
                    "replies": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/176758\/replies\/"
                }
            }
        }
    ]
}