Skip to main content

pages/{pageid}/tree (GET)

Overview

Builds a site map starting from a given 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
startpage bool? For HTML sitemap, indicates if the start page should be included (default: true)
format {xml, html, google}? Result format (default: xml)
include string? Include additional page information. Valid values: user, lastmodified, revision or properties
authenticate bool? Force authentication for request (default: false)

Return Codes

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

Message Format

Output (XML):

<pages>
    <page id="{int}" href="{uri}">
        <title>{text}</title> 
        <path>{text}</path> 
        <subpages>
            <page>...</page>
            ...
        </subpages>
    </page>
</pages>

Output (HTML):

<ul>
    <li>
        <a rel="internal" href="{uri}" title="{text}" pageid="{int}" class="{text}">{text}</a>
        <ul>
            <li>...</li>
            ...
        </ul>
    </li>
</ul>

Output (sitemap): Refer to http://www.google.com/schemas/sitemap/0.84

Implementation Notes

Redirect and archived pages are not included in the sitemap.

Use GET:pages to retrieve the full sitemap.

C# Code Sample: Retrieve Sitemap from Root Page

The following code example retrieves the sitemap from the page called "Page Title" in XML format:

Sample Code

Plug p = Plug.New("http://deki-hayes/@api/deki");
p.At("users", "authenticate").WithCredentials("admin", "password").Get();
p.At("pages", "=Page_Title").With("format", "xml").Get();

Sample Response from executing Code

Sample response indicating that "Page Title" has one subpage called "Subpage 1":

<pages>
    <page id="31" href="http://deki-hayes/@api/deki/pages/31">
        <title>Page Title</title> 
        <path>Page_Title</path> 
        <subpages>
            <page id="32" href="http://deki-hayes/@api/deki/pages/32">
                <title>Subpage 1</title> 
                <path>Page_Title/Subpage_1</path> 
                <subpages /> 
            </page>
        </subpages>
    </page>
</pages>

Curl Code Sample: Retrieve Sitemap from Root Page

This command basically does a recursive search for subpages. The following will return a sitemap with page "foo" as the root:

Sample Code

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

Sample Response from executing Code

The response given by running the command on a page with two subpages and one sub-subpage:

Content-Type: application/xml

<pages>
  <page id="565" href="http://192.168.59.128/@api/deki/pages/565?redirects=0">
    <uri.ui>http://192.168.59.128/Bar</uri.ui>
    <title>Bar</title>
    <path>Bar</path>
    <namespace>main</namespace>
    <subpages>
      <page id="600" href="http://192.168.59.128/@api/deki/pages/600?redirects=0">
        <uri.ui>http://192.168.59.128/Bar/Foo</uri.ui>
        <title>Foo</title>
        <path>Bar/Foo</path>
        <namespace>main</namespace>
        <subpages>
          <page id="601" href="http://192.168.59.128/@api/deki/pages/601?redirects=0">
            <uri.ui>http://192.168.59.128/Bar/Foo/Kung_Fu</uri.ui>
            <title>Kung Fu</title>
            <path>Bar/Foo/Kung_Fu</path>
            <namespace>main</namespace>
            <subpages/>
          </page>
        </subpages>
      </page>
      <page id="602" href="http://192.168.59.128/@api/deki/pages/602?redirects=0">
        <uri.ui>http://192.168.59.128/Bar/Mars</uri.ui>
        <title>Mars</title>
        <path>Bar/Mars</path>
        <namespace>main</namespace>
        <subpages/>
      </page>
    </subpages>
  </page>
</pages>

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?