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": 118261,
    "comments": [
        {
            "ID": 213506,
            "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": 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-10-25T20:43:28+00:00",
            "URL": "http:\/\/en.blog.wordpress.com\/2014\/10\/24\/the-namos-are-coming-the-namos-are-coming\/comment-page-1\/#comment-213506",
            "short_URL": "http:\/\/wp.me\/pf2B5-7z1%23comment-213506",
            "content": "<p>No, there&#8217;s a different themed version each month, and the main, free-for-all version is in November. The November information will be up there shortly.<\/p>\n",
            "status": "approved",
            "parent": {
                "ID": 213502,
                "type": "comment",
                "link": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/213502"
            },
            "type": "comment",
            "like_count": 0,
            "i_like": false,
            "meta": {
                "links": {
                    "self": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/213506",
                    "help": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/213506\/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\/213506\/replies\/",
                    "likes": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/213506\/likes\/"
                }
            }
        },
        {
            "ID": 213503,
            "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": 29443725,
                "login": "heatherglomb",
                "email": false,
                "name": "heatherglomb",
                "nice_name": "heatherglomb",
                "URL": "",
                "avatar_URL": "https:\/\/2.gravatar.com\/avatar\/e53a6eedf0d0ba5946ae4bed0dca8e21?s=96&d=retro",
                "profile_URL": "http:\/\/en.gravatar.com\/heatherglomb",
                "site_ID": 77558398
            },
            "date": "2014-10-25T20:08:31+00:00",
            "URL": "http:\/\/en.blog.wordpress.com\/2014\/10\/24\/the-namos-are-coming-the-namos-are-coming\/comment-page-1\/#comment-213503",
            "short_URL": "http:\/\/wp.me\/pf2B5-7z1%23comment-213503",
            "content": "<p>I am absolutely participating. I won the last two years, and I&#8217;m going to win again this year. Last year&#8217;s NaNo project is in edits right now, which is painful and NaNo will be a welcome reprieve. If anyone wants to buddy up, my tag is feather face. It&#8217;s a childhood nickname. I may even partake in NaNoBloMo, to track my progress. You can see it for yourself, heatherglomb.com. Just click follow. <span class='wp-smiley wp-emoji wp-emoji-smile' title=':)'>:)<\/span><\/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\/213503",
                    "help": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/213503\/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\/213503\/replies\/",
                    "likes": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/213503\/likes\/"
                }
            }
        },
        {
            "ID": 213502,
            "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": 59914039,
                "login": "saltysweetlifeblog",
                "email": false,
                "name": "Salty Sweet Life",
                "nice_name": "saltysweetlifeblog",
                "URL": "http:\/\/saltysweetlifedotcom.wordpress.com",
                "avatar_URL": "https:\/\/0.gravatar.com\/avatar\/000aa307d968f0f39533fa8a77629a1b?s=96&d=retro",
                "profile_URL": "http:\/\/en.gravatar.com\/saltysweetlifeblog",
                "site_ID": 62586845
            },
            "date": "2014-10-25T19:49:28+00:00",
            "URL": "http:\/\/en.blog.wordpress.com\/2014\/10\/24\/the-namos-are-coming-the-namos-are-coming\/comment-page-1\/#comment-213502",
            "short_URL": "http:\/\/wp.me\/pf2B5-7z1%23comment-213502",
            "content": "<p>I just followed the link that you posted to BlogHer and it appears that NaBloPoMo is in October. Did we miss it?<\/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\/213502",
                    "help": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/213502\/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\/213502\/replies\/",
                    "likes": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/213502\/likes\/"
                }
            }
        },
        {
            "ID": 213499,
            "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": 70012270,
                "login": "johnsona88",
                "email": false,
                "name": "AJ",
                "nice_name": "johnsona88",
                "URL": "http:\/\/becomingsurefooted.wordpress.com",
                "avatar_URL": "https:\/\/0.gravatar.com\/avatar\/6c0c69dbb254419d7dfc8c5ccad76eea?s=96&d=retro",
                "profile_URL": "http:\/\/en.gravatar.com\/johnsona88",
                "site_ID": 73212560
            },
            "date": "2014-10-25T19:08:54+00:00",
            "URL": "http:\/\/en.blog.wordpress.com\/2014\/10\/24\/the-namos-are-coming-the-namos-are-coming\/comment-page-1\/#comment-213499",
            "short_URL": "http:\/\/wp.me\/pf2B5-7z1%23comment-213499",
            "content": "<p>I&#8217;m looking forward to this! What a great 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\/213499",
                    "help": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/213499\/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\/213499\/replies\/",
                    "likes": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/213499\/likes\/"
                }
            }
        },
        {
            "ID": 213497,
            "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": 41180914,
                "login": "brokenspiners",
                "email": false,
                "name": "Banned Books Club",
                "nice_name": "brokenspiners",
                "URL": "http:\/\/brokenspiners.wordpress.com",
                "avatar_URL": "https:\/\/2.gravatar.com\/avatar\/80be4c56a59e119de90536a71846f78b?s=96&d=retro",
                "profile_URL": "http:\/\/en.gravatar.com\/brokenspiners",
                "site_ID": 41758107
            },
            "date": "2014-10-25T18:22:27+00:00",
            "URL": "http:\/\/en.blog.wordpress.com\/2014\/10\/24\/the-namos-are-coming-the-namos-are-coming\/comment-page-1\/#comment-213497",
            "short_URL": "http:\/\/wp.me\/pf2B5-7z1%23comment-213497",
            "content": "<p>Getting my blog posts together now. I&#8217;m determined I&#8217;m going to finish it this year! <span class='wp-smiley wp-emoji wp-emoji-smile' title=':)'>:)<\/span> Good Luck to everyone, whichever NaMo you choose.<\/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\/213497",
                    "help": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/213497\/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\/213497\/replies\/",
                    "likes": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/213497\/likes\/"
                }
            }
        }
    ]
}