Download & Extend

Services Entity API

Integration of Services and Entity API.

You can define an endpoint via Services and publish any entity data relying in Entity API.
This module allows to get entities by properties or fields and also paging and related entities that are defined properly.

Services Entity 2.x Branch

The services entity 2.x branch is a rewrite to add new functionality and enable easier extensibility. There is a new pluggable architecture that allows the rendering of the output to easily be changed.

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.

One of the major new functionalities in the 2.x branch is a pluggable controller. These controllers allow a class to completely override the input and output of the services. This module provides a few classes to use. The first one is the Generic controller. This controller returns and expects exactly what the Entity API module wants for it's save and load functions.

The second controller is a bit more interesting. It is the 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

Automatically generated endpoint 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 param[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.

    Services Entity 1.x Branch

    Examples

    (path to endpoint and entity name may vary)

    • All the products: api/1.0/entity_commerce_product
    • All the products of one type: api/1.0/entity_commerce_product?bundle=machine_name
    • Also you can filter by fields so you only get those fields you want: api/1.0/entity_commerce_product?fields=title,sku
    • Or combined: api/1.0/entity_commerce_product?bundle=machine_name&fields=title,sku
    • Results are paged in sets of 20, you can get any page by using page parameter. Note: page starts at 0: api/1.0/entity_commerce_product?page=1
    • Getting products by id: api/1.0/entity_commerce_product/1
    • Filtering which fields you want to retrieve: api/1.0/entity_commerce_product/1?fields=title,sku
    • Getting products by sku or other unique properties: api/1.0/entity_commerce_product/sku:ABC1234

    Fields support getting given fields from relationships, i.e getting some fields of related products:
    api/1.0/entity_commerce_product/1?fields=title,field_relatedproducts:title,field_relatedproducts:sku

    For the rest of entity types the API calls would be the same, using entity_machine_name instead of entity_commerce_product, for example entity_node.

    Related projects:

    Downloads

    Recommended releases

    Version Downloads Date Links
    7.x-2.0-alpha3 tar.gz (18.55 KB) | zip (24.75 KB) 2013-Mar-29 Notes

    Development releases

    Version Downloads Date Links
    7.x-2.x-dev tar.gz (18.59 KB) | zip (24.78 KB) 2013-Apr-19 Notes
    7.x-1.x-dev tar.gz (11.99 KB) | zip (13.67 KB) 2012-Sep-01 Notes

    Project Information


    Maintainers for Services Entity API

    • joachim - 13 commits
      last: 4 weeks ago, first: 9 weeks ago
    • randallknutson - 8 commits
      last: 26 weeks ago, first: 28 weeks ago
    • pcambra - 2 commits
      last: 37 weeks ago, first: 37 weeks ago

    Issues for Services Entity API

    To avoid duplicates, please search before submitting a new issue.
    All issues
    Bug reports
    Statistics (2 years)
    New issues
    Open bugs
    Participants
    nobody click here