Skip to main content

pages/{pageid}/comments (GET)

Overview

Retrieve the comments on a page

  • REST Method: GET
  • Method Access: public

Uri Parameters

Name Type Description
pageid string either an integer page ID, "home", or "=" followed by a double uri-encoded page title

Query Parameters

Name Type Description
authenticate bool? Force authentication for request (default: false)
postedbyuserid int? Only return comments posted by the id of a user
depth string? Use 'infinity' to return comments from all descendant pages. (default: 0)
offset int? Number of items to skip. Must be a positive number or 0 to not skip any. (default: 0)
limit string? Maximum number of items to retrieve. Must be a positive number or 'all' to retrieve all items. (default: 100)
filter string? Comments to return: any, nondeleted. default: nondeleted
format {xml, atom}? Output format (default: xml).
sortby {date.posted}? Sort field. Prefix value with '-' to sort descending. (default: date.posted)

Return Codes

Name Value Description
OK 200 The request completed successfully
Bad Request 400 Invalid input parameter or request body
Forbidden 403 Read access to the page is required
Not Found 404 The requested page could not be found

Message Format

Output:

<comments count="{int}" href="{uri}">
    <comment id="{int}" href="{uri}">
        <page.parent id="{uri}" href="{uri}">
            <title>{text}</title> 
            <path>{text}</path> 
        </page.parent>
        <user.createdby id="{int}" href="{uri}">
            <nick>{text}</nick> 
            <username>{text}</username> 
            <email>{text}</email> 
        </user.createdby>
        <date.posted>{date}</date.posted> 
        <title>{text}</title> 
        <number>{int}</number> 
        <content type="{mimetype}" href="{uri}">{text}</content> 
        <user.editedby id="{int}" href="{uri}">
            <nick>{text}</nick> 
            <username>{text}</username> 
            <email>{text}</email> 
        </user.editedby>
        <date.edited>{date}</date.edited> 
        <user.deletedby id="{int}" href="{uri}">
            <nick>{text}</nick> 
            <username>{text}</username> 
            <email>{text}</email> 
        </user.deletedby>
        <date.deleted>{date}</date.deleted> 
    </comment>
    ...
</comments>

Implementation Notes

The user.deletedby and date.deleted elements only exist if the comment has been deleted.

Use POST:pages/{pageid}/comments to add new comments to the page.

C# Code Sample: Retrieve Page Comments

The following code example retrieves comments on the home page:

Sample Code

Plug p = Plug.New("http://help.mindtouch.us/@api/deki");
p.At("users", "authenticate").WithCredentials("admin", "password").Get();
p.At("pages", "home", "comments").Get();

Sample Response from executing Code

Sample response indicating that the home page has one comment:

<comments count="1" href="http://help.mindtouch.us/@api/deki/pages/29/comments">
    <comment id="1" href="http://help.mindtouch.us/@api/deki/pages/29/comments/1">
        <page.parent id="29" href="http://help.mindtouch.us/@api/deki/pages/29">
            <title>DekiWiki (Hayes)</title> 
            <path /> 
        </page.parent>
        <user.createdby id="1" href="http://help.mindtouch.us/@api/deki/users/1">
            <nick>Admin</nick> 
            <username>Admin</username> 
            <email>admin@mindtouch.com</email> 
        </user.createdby>
        <date.posted>2007-08-23T09:52:07Z</date.posted> 
        <title /> 
        <number>1</number> 
        <content type="text/plain" href="http://help.mindtouch.us/@api/deki/pages/29/comments/1/content">Comment text</content> 
    </comment>
</comments>

Implementation notes 

Add notes about requirements or config values

Curl Code Sample: Retrieve Page Comments

The following command retrieves a list of comments made on page "foo":

Sample Code

curl -u username:password -i http://mindtouch.address/@api/deki/pages/=foo/comments

Sample Response from executing Code

{pageid} = Gotham, contains 1 comment.

<comments count="1" totalcount="1" href="http://192.168.59.128/@api/deki/pages/596/comments">
  <comment id="22" href="http://192.168.59.128/@api/deki/pages/596/comments/1">
    <user.createdby id="1" href="http://192.168.59.128/@api/deki/users/1">
      <nick>Admin</nick>
      <username>Admin</username>
      <email hidden="true"/>
      <hash.email>64e1b8d34f425d19e1ee2ea7236d3028</hash.email>
      <uri.gravatar>http://www.gravatar.com/avatar/64e1b8d34f425d19e1ee2ea7236d3028</uri.gravatar>
    </user.createdby>
    <date.posted>2010-01-28T20:13:13Z</date.posted>
    <title/>
    <number>1</number>
    <content type="text/plain; charset=utf-8" href="http://192.168.59.128/@api/deki/pages/596/comments/1/content">I am the Batman</content>
  </comment>
</comments>

Implementation notes 

curl flags

-u
Provides external user authentication. Note that if anonymous access is available and authentication is not forced, this flag may be omitted.
-i
Outputs the HTTP response headers. Useful for debugging.

Pages

To view a list of all pages, follow the instructions here.
  • Was this article helpful?