Content API - Documentation topics on: api,content api,rest,.

Content API

Retrieves a list or a piece of content in JSON or XML format.

URL: /api/content/

RESTful Content

The easiest way to see how to use the restful content API is to click on the Content tab and search for the content you want to display. Click on Search --> Show Query, the URL is shown as: Rest API Call URLEncoded (Use this URL for external aplications or javascript on your page). You can either click on this URL or copy/paste to use on your Widget Code.

Authentication

This API supports the same REST auth infrastructure as other rest apis in dotcms. There are 4 ways to authenticate.

  • user/xxx/password/yyy in the URI
  • basic http/https authentication (base64 encoded)
  • DOTAUTH header similar to basic auth and base64 encoded, e.g. setHeader("DOTAUTH", base64.encode("admin@dotcms.com:admin"))
  • Session based (form based login) for frontend or backend logged in user

Parameters:

query: (Mandatory unless you are using the 'id' param) Lucene query to search for content.

Usage: /api/content/query/<your-query>
Example usage: /api/content/query/+contentType:TestFilesAndImages +(conhost:48190c8c-42c4-
46af-8d1a-0cd5db894797 conhost:SYSTEM_HOST) +languageId:1 +deleted:false +working:true

id: (Mandatory unless you are using the 'query' param) identifier of the contentlet to search for

Usage: /api/content/id/<an-identifier>
Example usage: /api/content/id/17723c01-d9ae-4ca9-b11f-6125961509c1

inode: (Mandatory unless you are using the 'query' param) inode of the contentlet to search for

Usage: /api/content/inode/<an-inode>
Example usage: /api/content/inode/17723c01-d9ae-4ca9-b11f-6125961509c1


type: (Optional) Specifies if the resultant content must be returned in JSON, XML or JSONP (available for 2.6 and above) format.
Defaults to 'json'.

Usage: /api/content/<json|xml|jsonp>
Example usage: /content/type/json

render: (Optional) Determines if the retrieved content must be parsed or not (only in case the
content is a widget).

Usage: /api/content/render/<true|false>
Example usage: /api/content/render/true

orderby: (Optional) Specifies an order criteria for the results.
Defaults to ' moddate desc'

Usage: /api/content/orderby/<order- criteria>
Example usage: /api/content/query/+live:true/orderby/moddate asc/

offset: (Optional) Specifies an offset for the resulting list, so if given, the resulting list will start
from this position.

Usage: /api/content/offset/<integer-offset>
Example usage: /api/content/query/+live:true/orderby/moddate asc/offset/10

limit: (Optional) Specifies a limit number for the resulting list.

Usage: /api/content/limit/<integer-limit>
Example usage: /api/content/query/+live:true/orderby/moddate asc/offset/10/limit/30

user/password: (Optional) Specifies a username or email and a password to use when searching the content.

Usage: /api/content/user/<username-or-email>/password/<password>
Example usage: /api/content/query/+live:true/user/admin@dotcms.com/password/123

See the following documentation for different content submission form methodologies via the Content API: