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": 117515,
    "comments": [
        {
            "ID": 211713,
            "post": {
                "ID": 28481,
                "title": "Basis, Edin, and Forefront: A Look at Business Themes",
                "type": "post",
                "link": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/posts\/28481"
            },
            "author": {
                "ID": 51095103,
                "login": "kevinab825",
                "email": false,
                "name": "Kevin Bradberry",
                "nice_name": "kevinab825",
                "URL": "",
                "avatar_URL": "https:\/\/0.gravatar.com\/avatar\/33d65356ea710f15156d81cff8524d67?s=96&d=retro",
                "profile_URL": "http:\/\/en.gravatar.com\/kevinab825",
                "site_ID": 62843248
            },
            "date": "2014-09-15T14:50:45+00:00",
            "URL": "http:\/\/en.blog.wordpress.com\/2014\/09\/12\/professional-sites\/comment-page-1\/#comment-211713",
            "short_URL": "http:\/\/wp.me\/pf2B5-7pn%23comment-211713",
            "content": "<p>I love this inside look on how themes are being used. Please do many more! I had no idea any theme available on WordPress.com allowed drag n&#8217; drop building (as you say Basis can do).<\/p>\n<p>My favorite design of this bunch was roam&amp;home.<\/p>\n",
            "status": "approved",
            "parent": false,
            "type": "comment",
            "meta": {
                "links": {
                    "self": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/211713",
                    "help": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/211713\/help",
                    "site": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907",
                    "post": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/posts\/28481",
                    "replies": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/211713\/replies\/",
                    "likes": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/211713\/likes\/"
                }
            }
        },
        {
            "ID": 211707,
            "post": {
                "ID": 28615,
                "title": "Gmail Password Leak Update",
                "type": "post",
                "link": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/posts\/28615"
            },
            "author": {
                "ID": 43276505,
                "login": "ldlagarino",
                "email": false,
                "name": "ldlagarino",
                "nice_name": "ldlagarino",
                "URL": "http:\/\/ldlagarinowordnovice.wordpress.com",
                "avatar_URL": "https:\/\/0.gravatar.com\/avatar\/f2731ea95e2badc3d051bf4a67f78c7a?s=96&d=retro",
                "profile_URL": "http:\/\/en.gravatar.com\/ldlagarino",
                "site_ID": 43890455
            },
            "date": "2014-09-15T12:33:13+00:00",
            "URL": "http:\/\/en.blog.wordpress.com\/2014\/09\/12\/gmail-password-leak-update\/comment-page-2\/#comment-211707",
            "short_URL": "http:\/\/wp.me\/pf2B5-7rx%23comment-211707",
            "content": "<p>It may be a coincidence, but yesterday, Sunday, September 14, I logged into WordPress and discovered one of my posts had vanished. The post itself is not a big deal. It was a first draft of a scene from a screenplay in progress that has since been rewritten. I left it in order to have confirmation of the posting date. For something to vanish, it must have been moved somewhere or been deleted, and not by me.<\/p>\n",
            "status": "approved",
            "parent": false,
            "type": "comment",
            "meta": {
                "links": {
                    "self": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/211707",
                    "help": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/211707\/help",
                    "site": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907",
                    "post": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/posts\/28615",
                    "replies": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/211707\/replies\/",
                    "likes": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/211707\/likes\/"
                }
            }
        },
        {
            "ID": 211706,
            "post": {
                "ID": 28615,
                "title": "Gmail Password Leak Update",
                "type": "post",
                "link": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/posts\/28615"
            },
            "author": {
                "ID": 50672613,
                "login": "golnaran",
                "email": false,
                "name": "GolNaran",
                "nice_name": "golnaran",
                "URL": "http:\/\/golnaranart.wordpress.com\/",
                "avatar_URL": "https:\/\/2.gravatar.com\/avatar\/54050fddbdc0f3333d7aef6e7202157e?s=96&d=retro",
                "profile_URL": "http:\/\/en.gravatar.com\/golnaran",
                "site_ID": 71202317
            },
            "date": "2014-09-15T12:24:10+00:00",
            "URL": "http:\/\/en.blog.wordpress.com\/2014\/09\/12\/gmail-password-leak-update\/comment-page-2\/#comment-211706",
            "short_URL": "http:\/\/wp.me\/pf2B5-7rx%23comment-211706",
            "content": "<p>Thank you so much!<\/p>\n",
            "status": "approved",
            "parent": false,
            "type": "comment",
            "meta": {
                "links": {
                    "self": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/211706",
                    "help": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/211706\/help",
                    "site": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907",
                    "post": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/posts\/28615",
                    "replies": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/211706\/replies\/",
                    "likes": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/211706\/likes\/"
                }
            }
        },
        {
            "ID": 211704,
            "post": {
                "ID": 28615,
                "title": "Gmail Password Leak Update",
                "type": "post",
                "link": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/posts\/28615"
            },
            "author": {
                "ID": 102,
                "login": "dllh",
                "email": false,
                "name": "Daryl L. L. Houston",
                "nice_name": "dllh",
                "URL": "http:\/\/daryl.learnhouston.com\/",
                "avatar_URL": "https:\/\/0.gravatar.com\/avatar\/6ea52ba884713c11a9f814dde6867c97?s=96&d=retro",
                "profile_URL": "http:\/\/en.gravatar.com\/dllh",
                "site_ID": 7
            },
            "date": "2014-09-15T11:29:28+00:00",
            "URL": "http:\/\/en.blog.wordpress.com\/2014\/09\/12\/gmail-password-leak-update\/comment-page-2\/#comment-211704",
            "short_URL": "http:\/\/wp.me\/pf2B5-7rx%23comment-211704",
            "content": "<p>The security item isn&#8217;t in the old-style dashboard; it&#8217;s in the settings available from the wordpress.com home page. Try going there, then hovering over the avatar at top right, then look for Settings.<\/p>\n",
            "status": "approved",
            "parent": {
                "ID": 211703,
                "type": "comment",
                "link": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/211703"
            },
            "type": "comment",
            "meta": {
                "links": {
                    "self": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/211704",
                    "help": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/211704\/help",
                    "site": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907",
                    "post": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/posts\/28615",
                    "replies": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/211704\/replies\/",
                    "likes": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/211704\/likes\/"
                }
            }
        },
        {
            "ID": 211703,
            "post": {
                "ID": 28615,
                "title": "Gmail Password Leak Update",
                "type": "post",
                "link": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/posts\/28615"
            },
            "author": {
                "ID": 50672613,
                "login": "golnaran",
                "email": false,
                "name": "GolNaran",
                "nice_name": "golnaran",
                "URL": "http:\/\/golnaranart.wordpress.com\/",
                "avatar_URL": "https:\/\/2.gravatar.com\/avatar\/54050fddbdc0f3333d7aef6e7202157e?s=96&d=retro",
                "profile_URL": "http:\/\/en.gravatar.com\/golnaran",
                "site_ID": 71202317
            },
            "date": "2014-09-15T10:22:33+00:00",
            "URL": "http:\/\/en.blog.wordpress.com\/2014\/09\/12\/gmail-password-leak-update\/comment-page-2\/#comment-211703",
            "short_URL": "http:\/\/wp.me\/pf2B5-7rx%23comment-211703",
            "content": "<p>There is not any &#8220;security&#8221; submenu in my dashboard.<br \/>\nWhat should I do?<\/p>\n",
            "status": "approved",
            "parent": false,
            "type": "comment",
            "meta": {
                "links": {
                    "self": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/211703",
                    "help": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/211703\/help",
                    "site": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907",
                    "post": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/posts\/28615",
                    "replies": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/211703\/replies\/",
                    "likes": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/211703\/likes\/"
                }
            }
        }
    ]
}