I must admit to being a big fan of RESTful APIs, but I'm skeptical of treating any technical approach as being universally applicable. Are there any likely scenarios where a RESTful API for a web service is not going to be a good idea?
I must admit to being a big fan of RESTful APIs, but I'm skeptical of treating any technical approach as being universally applicable. Are there any likely scenarios where a RESTful API for a web service is not going to be a good idea?
Stateless:
The disadvantage is that it may decrease network performance by increasing
the repetitive data (per-interaction overhead) sent in a series of requests,
since that data cannot be left on the server in a shared context. In addition,
placing the application state on the client-side reduces the server's
control over consistent application behavior, since the application becomes
dependent on the correct implementation of semantics across multiple
client versions.
Cache: The trade-off, however, is that a cache can decrease reliability if stale
data within the cache differs significantly from the data that would
have been obtained had the request been sent directly to the server.
Uniform Interface: The trade-off, though, is that a uniform interface degrades efficiency,
since information is transferred in a standardized form rather than one which
is specific to an application's needs. The REST interface is designed
to be efficient for large-grain hypermedia data transfer, optimizing
for the common case of the Web, but resulting in an interface that is not
optimal for other forms of architectural interaction.
Layered System: The primary disadvantage of layered systems is that they add overhead
and latency to the processing of data, reducing user-perceived performance.
I fully recommend reading the thesis instead of relying on the vox populi that often times misrepresents what these concepts really mean and what advantages they bring to the architecture of the system: http://www.ics.uci.edu/~fielding/pubs/dissertation/rest_arch...Zemanta's API is one of them. We're not dealing with resources, we're dealing with analysis of text (natural language processing, information retrieval, etc...), so except of the basic url scheme, there's not much that you can take from the RESTful idea.
You could just POST the text, get back a bunch of links to the resources and then GET the ones you're interested in.
Assuming that certain "objects" are more expensive than others to generate, a resource-based view with lazily-generated representations could be more efficient than wasting resources without knowing if the client needs them or not.
What's expensive is the analysis of the original text, not creation of the objects. If you want to do what you are saying you would need to create and store objects server side in order not to have to re-do the analysis the second time around. There's no point in that.
When you have a lot of high-speed data, you will want to go with sockets and a live stream of small bits of data. Like Twitter's firehose for instance, or getting Wall Street data for your bot trader.
For example we implemented our API with both XML-RPC and REST + JSON interfaces (http://www.memset.com/apidocs/intro.html). All the methods are available and work the same way in both interfaces. There's some extra work to deal with some of the types (ie. dates in JSON), but it's not too difficult.
So we have one implementation/docs, but two interfaces to access to it.
Edit: One of the interesting things about their RESTful API is that different versions of the API are explicitly in there as resources.
Sorry if I didn't explain it very well, the docs are clearer though.
A good rule of thumb is: if the documentation mentions "methods" as anything other than the uniform ones (if you're using HTTP, that would be GET, POST, etc), then it's RPC, not REST.
Note: I'm not saying your API is bad; RPC is a completely valid model. I'm just saying it's not RESTful.
EDIT: to be fair, in the docs we never say it's a RESTFul API, it was MY mistake in my first comment.