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": 118679,
    "comments": [
        {
            "ID": 214575,
            "post": {
                "ID": 29255,
                "title": "Explore Longform with Writing 201",
                "type": "post",
                "link": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/posts\/29255"
            },
            "author": {
                "ID": 28495047,
                "login": "mangiachetifabenebimbo",
                "email": false,
                "name": "mangiachetifabenebimbo!",
                "nice_name": "mangiachetifabenebimbo",
                "URL": "http:\/\/mangiachetifabenebimbo.wordpress.com",
                "avatar_URL": "https:\/\/2.gravatar.com\/avatar\/569e8bff7a3f488843ffa15d09905e63?s=96&d=retro",
                "profile_URL": "http:\/\/en.gravatar.com\/mangiachetifabenebimbo",
                "site_ID": 28954068
            },
            "date": "2014-11-25T18:40:31+00:00",
            "URL": "http:\/\/en.blog.wordpress.com\/2014\/11\/21\/writing-201-longform\/comment-page-1\/#comment-214575",
            "short_URL": "http:\/\/wp.me\/pf2B5-7BR%23comment-214575",
            "content": "<p>perfect! now I know! thank you<\/p>\n",
            "status": "approved",
            "parent": {
                "ID": 214549,
                "type": "comment",
                "link": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/214549"
            },
            "type": "comment",
            "like_count": 0,
            "i_like": false,
            "meta": {
                "links": {
                    "self": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/214575",
                    "help": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/214575\/help",
                    "site": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907",
                    "post": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/posts\/29255",
                    "replies": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/214575\/replies\/",
                    "likes": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/214575\/likes\/"
                }
            }
        },
        {
            "ID": 214574,
            "post": {
                "ID": 29255,
                "title": "Explore Longform with Writing 201",
                "type": "post",
                "link": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/posts\/29255"
            },
            "author": {
                "ID": 21477026,
                "login": "cortlandwriter",
                "email": false,
                "name": "Mark Anderson",
                "nice_name": "cortlandwriter",
                "URL": "http:\/\/cortlandwriter.wordpress.com",
                "avatar_URL": "https:\/\/0.gravatar.com\/avatar\/9acc93dc2c4c43011f12231f8ea4e69a?s=96&d=retro",
                "profile_URL": "http:\/\/en.gravatar.com\/cortlandwriter",
                "site_ID": 20898149
            },
            "date": "2014-11-25T18:39:54+00:00",
            "URL": "http:\/\/en.blog.wordpress.com\/2014\/11\/21\/writing-201-longform\/comment-page-1\/#comment-214574",
            "short_URL": "http:\/\/wp.me\/pf2B5-7BR%23comment-214574",
            "content": "<p>What a wonderful idea! I loo forward to jumping in and learning lots and becoming a better writer in the process! <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\/214574",
                    "help": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/214574\/help",
                    "site": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907",
                    "post": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/posts\/29255",
                    "replies": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/214574\/replies\/",
                    "likes": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/214574\/likes\/"
                }
            }
        },
        {
            "ID": 214573,
            "post": {
                "ID": 29255,
                "title": "Explore Longform with Writing 201",
                "type": "post",
                "link": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/posts\/29255"
            },
            "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-11-25T18:30:26+00:00",
            "URL": "http:\/\/en.blog.wordpress.com\/2014\/11\/21\/writing-201-longform\/comment-page-1\/#comment-214573",
            "short_URL": "http:\/\/wp.me\/pf2B5-7BR%23comment-214573",
            "content": "<p>Thanks for sharing it! We&#8217;ll have other writing courses coming up in the new year; maybe one of them will work for you <span class='wp-smiley wp-emoji wp-emoji-smile' title=':)'>:)<\/span><\/p>\n",
            "status": "approved",
            "parent": {
                "ID": 214572,
                "type": "comment",
                "link": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/214572"
            },
            "type": "comment",
            "like_count": 0,
            "i_like": false,
            "meta": {
                "links": {
                    "self": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/214573",
                    "help": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/214573\/help",
                    "site": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907",
                    "post": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/posts\/29255",
                    "replies": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/214573\/replies\/",
                    "likes": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/214573\/likes\/"
                }
            }
        },
        {
            "ID": 214572,
            "post": {
                "ID": 29255,
                "title": "Explore Longform with Writing 201",
                "type": "post",
                "link": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/posts\/29255"
            },
            "author": {
                "ID": 16457430,
                "login": "giftsandthings",
                "email": false,
                "name": "SGC Admin",
                "nice_name": "giftsandthings",
                "URL": "http:\/\/www.serenitysgiftcove.com",
                "avatar_URL": "https:\/\/0.gravatar.com\/avatar\/faf8df1dfb4ec8a9f645f93c693fa8bf?s=96&d=retro",
                "profile_URL": "http:\/\/en.gravatar.com\/giftsandthings",
                "site_ID": 15867789
            },
            "date": "2014-11-25T16:59:28+00:00",
            "URL": "http:\/\/en.blog.wordpress.com\/2014\/11\/21\/writing-201-longform\/comment-page-1\/#comment-214572",
            "short_URL": "http:\/\/wp.me\/pf2B5-7BR%23comment-214572",
            "content": "<p> <span class='wp-smiley wp-emoji wp-emoji-smile' title=':)'>:)<\/span> Gosh if I had the time, I am sure I could learn a thing or two from this course&#8230; <span class='wp-smiley wp-emoji wp-emoji-smile' title=':)'>:)<\/span> I have shared on our SGC facebook page though for any budding writer&#8217;s&#8230; Have a fabulous day&#8230;:)<\/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\/214572",
                    "help": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/214572\/help",
                    "site": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907",
                    "post": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/posts\/29255",
                    "replies": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/214572\/replies\/",
                    "likes": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/214572\/likes\/"
                }
            }
        },
        {
            "ID": 214571,
            "post": {
                "ID": 29255,
                "title": "Explore Longform with Writing 201",
                "type": "post",
                "link": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/posts\/29255"
            },
            "author": {
                "ID": 75854986,
                "login": "ifychucks",
                "email": false,
                "name": "ifychucks",
                "nice_name": "ifychucks",
                "URL": "http:\/\/ifychucksblog.wordpress.com",
                "avatar_URL": "https:\/\/2.gravatar.com\/avatar\/57c71893788abd11f31f9d5bb7bf5a36?s=96&d=retro",
                "profile_URL": "http:\/\/en.gravatar.com\/ifychucks",
                "site_ID": 79561487
            },
            "date": "2014-11-25T16:46:47+00:00",
            "URL": "http:\/\/en.blog.wordpress.com\/2014\/11\/21\/writing-201-longform\/comment-page-1\/#comment-214571",
            "short_URL": "http:\/\/wp.me\/pf2B5-7BR%23comment-214571",
            "content": "<p>Happy to be part of it. Hoping to learn to improve.<\/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\/214571",
                    "help": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/214571\/help",
                    "site": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907",
                    "post": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/posts\/29255",
                    "replies": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/214571\/replies\/",
                    "likes": "https:\/\/public-api.wordpress.com\/rest\/v1\/sites\/3584907\/comments\/214571\/likes\/"
                }
            }
        }
    ]
}