Drupal as the CMS for a restful API for an iPhone App

For a recent contract the client stipulated Drupal as the CMS to support the web services for their iPhone App. Our advice was to go for a lighter framework that better supports web services and gives better control over things like http headers and the json output. But sometimes you just have to suck it in and do the best you can with what the client wants...

We made our start with a Drupal 7 minimal install profile and used a number of contributed modules to provide the bulk of the required functionality, with some enhancements via custom coded modules.

Views content based RESTful server

These are the core and contributed modules we used to set up the base RESTful service:

The data output for the services endpoint in this application is defined in queries built using Views.


Using these tools has some drawbacks. If you're used to building RESTful services closer to the metal, may come as a shock.

Don't try this at home.

I wouldn't recommend using Drupal to build web services. We took a contributed module approach with the hope that this would provide more stability in handover to the client. I'm still not sure about this - I think we could have achieved better control if we had done less 'the Drupal way' and trusted our code query the database and output the raw json, without dressing it up Views and the CMS interface, and introducing a level of cruft to the output. If you have the option to use other PHP tools, or Ruby on Rails, or something like Restify on node.js - I would recommend it.