I'd like some advice as I don't know if I'm doing this the correct way...
I'd like to create a web service to get a specific node type. I don't need create/update/delete functionality, just being able to retreive the data is enough. It also shouldn't contain any authentication (the data is public).
This node type contains several field collections. Each field collection could occur multiple times in the node. (for example, there's the node type "Car" which contains the field collections "Audi", "BMW", "Skoda". Each of these can occur multiple times in the node).
The JSON I'd like to return should look like this:
{"cars": {
"title": "newest cars",
"image": "http://www.example.com/image.jpg",
"audi": [
{
"title": "A1",
"price": "expensive"
},
{ "title": "A6",
"price": "very expensive"
}
],
"BMW": [
// multiple BMW's
],
}}
It's possible that zero cars of a specific brand are returned.
I've been looking how to do this in Drupal. I don't have much Drupal experience, so I'm sorry if this is a very easy thing.
I'm currently using the services module. I've had a look at this tutorial:
http://pingv.com/blog/an-introduction-drupal-7-restful-services
It looks pretty easy, however, the field collection module adds all fields in a different database table. With all fields I have, I'd have to join more than 20 tables in the query and the Drupal database can get pretty confusing this way.
I'm wondering if there's a much easier way to do this. I've already looked at other modules like "Services Views", but these don't seem to do the things I want:
- Return specific node (and specific node id) which contains field collections
- Return image url
- Return only the fields I want
- Return easy, readable names
- Accept certain parameters in the URL (which I'd like to define myself) to filter
Is there an easy way to do this or is the only way creating the very complex query?
Thanks!