views:

167

answers:

1

Is there a gem/plugin for defining an API in Rails?

I know you can have "RESTful routes" and render to different formats in controller actions, but I'm looking for a more all-around solution, including but not limited to the following:

I would like to declare which models to expose (arbitrary resources could also be declared, but convention should help me when they're mapped to models), which fields to make available and how the data should be laid out, which kind of authentication / authorization is needed for which resource / operation, what kind of throttling I want. It would also have an easy way to automatically output resources to different formats (without needing any template), and provide streaming and notification through webhooks and/or PubSubHubBub, as well as efficient caching.

Ideally, I could have this sit on top of ActiveRecord without even needing ActionController, so I could have a small, API-only app.

I know there's something along these lines for Django called django-piston, but I haven't used it myself and I'm not sure how much of the above it covers.

Is there anything like this in Rails? Or am I completely misguided in wanting this (and why?) and should instead fill this need with vanilla Rails plus a handful of plugins (which ones?)?

A: 

CloudKit could be a solution. Haven't looked much into it yet, but from the website:

# Build an API like this
require 'cloudkit'
expose :notes, :projects
obvio171
Not really what I was looking for. CoudKit is more like an HTTP front to storage. Parts of it could help though.
obvio171