Using the API

Last updated on
30 April 2025

Getting Started

The following section assumes you have an endpoint set up using the content at /api/content (see Services Configuration).

API Calls:

/api/content:
This is the index function, it will return any nodes that match applied parameters (see below). Note that the index will display metadata and some field info for the nodes, but not all of the content. If you want everything at once in the index, use the fields=all param.
/api/content/id
This is the view function which will show a specific node, where id is the node id, aka nid

A call to /api/content will return xml for the first 10 nodes, sorted by date created - descending by default. The first item will be the counts, which reveal the current page the user is on, how many items exist, how many items are shown per page etc. An example:

<item>
  <count>318</count>
  <pages>31</pages>
  <itemsPerPage>10</itemsPerPage>
  <currentPage>0</currentPage>
</item>

The second page can be exposed by navigating to /api/content?page=1 (pages start on 0). Assuming 10 is the default number of results to return, this exposes the second 10 results if there are over 10 published nodes in Drupal.

Query content using various parameter filters:

Parameters:

  • search_string=[test] Matches the string [test] against node titles
  • type=[type] Returns only a single node type
  • types[]=[type] Returns only the input node types types[]=blog&types[]=page
  • terms[]=[term id] Returns nodes labeled with any of the input terms
  • title=[title] Returns a node with an exact title match
  • created_before=[YYYY-MM-DD] Inclusive. Returns nodes created before the input date
  • created_after=[YYYY-MM-DD] Inclusive. Returns nodes created after the input date
  • changed_before=[YYYY-MM-DD] Inclusive. Returns nodes updated before the input date
  • changed_after=[YYYY-MM-DD] Inclusive. Returns nodes updated after the input date
  • limit=[limit] The number of items to return in a single request
  • sort=[sort field] A node field to sort results by, such as created, changed, nid
  • sort_order=[ASC|DESC] Choose whether to sort results ascending or descending
  • page=[page] The page number of results to return
  • fields=all Show all fields for a node, includes CCK, body, taxonomy etc.
  • fields[]=[field] The fields parameter can instead be an array of the fields you want returned. For example fields[]=nid&fields[]=title will only return the node's nid and title.

CCK Queries:

Any field can be queried by using field_[field name]=[value]. Example: /api/content?field_coauthor=jason will return all nodes with a cck coauthor field containing the value “jason.” Note that only exact matches are currently support for CCK queries.

Help improve this page

Page status: Not set

You can: