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 entityPOST {endpoint}/{entity}
Send the object data in the body.
Returns the id of the entity created.
Retrieves an entityGET {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 entityPUT {endpoint}/{entity}/{:entity_id}
Send the object data in the body.
Returns 200 if successful.
Deletes an entityDELETE {endpoint}/{entity}/{:entity_id}
Returns 200 if successful.
Index an entityGET {endpoint}/{entity}
Optional Parameters are:
Returns an array of objects.
Example: api/1.0/entity_node?fields=title,nid¶meters[type]=blog¶meters[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
Development releases
Project Information
- Maintenance status: Actively maintained
- Development status: Under active development
- Reported installs: 202 sites currently report using this module. View usage statistics.
- Downloads: 1,423
- Last modified: April 3, 2013