This module provides support for all Entity API entity types to Services. All entity types get a standard resource, similar to what Services provides for code entity types such as nodes.

This module allows to get entities by properties or fields and also paging and related entities that are defined properly.

Resources

Every Entity properly defined in the Entity API will be exposed as a resource to the Services module. Each of these entities will automatically have Create, Retrieve, Update, Delete and Index actions for them. In addition, any actions, targeted_actions and relationships from core entities that are defined in the services module will be moved over to them as well.

Resource controllers

This module allows pluggable controllers to completely override the input and output of the resources. This module provides a few classes to use:

  • Generic controller. This controller returns and expects exactly what the Entity API module wants for its CRUD functions: entity_create(), entity_save(), and entity_load_single().
  • Clean controller. Essentially there are a bunch of "drupalisms" in the way that Drupal stores data that you may not want to expose in your API. For example, a Name field would be located at field_name['ind'][0]['value'] = Steve. The clean controller will change this to name = Steve which is a lot cleaner. Essentially this is meant to be able to quickly and easily build up cross platform APIs for use with backbone, iOS or Android development. While there is some functionality lost with this, the generic controller is still available to anyone who needs the full information.

To switch controllers go to admin/structure/services/entity.

Examples

Creates an entity
POST {endpoint}/{entity}
Send the object data in the body.
Returns the id of the entity created.

Retrieves an entity
GET {endpoint}/{entity}/{:entity_id}
fields is an optional query string parameter to specify which fields to return. For example:
api/1.0/entity_node/1?fields=title,nid
Returns the entity.

Updates an entity
PUT {endpoint}/{entity}/{:entity_id}
Send the object data in the body.
Returns 200 if successful.

Deletes an entity
DELETE {endpoint}/{entity}/{:entity_id}
Returns 200 if successful.

Index an entity
GET {endpoint}/{entity}

Optional Parameters are:

  • (string) fields - A comma separated list of fields to get.
  • (array) parameters - Filter parameters array such as parameters[title]="test"
  • (int) page - The zero-based index of the page to get, defaults to 0.
  • (int) pagesize - Number of records to get per page.
  • (string) sort - Field to sort by.
  • (string) direction - Direction of the sort. ASC or DESC.

Returns an array of objects.

Example: api/1.0/entity_node?fields=title,nid&parameters[type]=blog&parameters[status]=1&page=0&pagesize=30&sort=title&direction=DESC

Also check out Services Docs for automatically documenting your API.

Related projects:

Project Information

Downloads