Convention for combining REST requests and replies?
rest
Solution
I think we need some standard way of doing this, but until then, you're probably on your own.
In the past I've had similar challenges when I wanted to do transactions spread across multiple resources. I invented new resources which described the actions I was about to make more clearly (subtracting 5 from account A and adding 5 to account B becomes a transaction with from and to members).
Maybe a similar (but more general) approach could be applied here by using another REST call as container;
POST /batchRequests { requests: [
{ method: 'POST', url: '/resource', payload: { ... } }
], transactional: false }
Which in turn returned a "BatchRequest" object containing results. It's pretty close to what Facebook did as well.
Problem
For a complex web application, one page view might require data of many different types. If you are doing client-side templating and pulling in this data from a RESTful web service, you may have to make a lot of requests to populate the page. Is there any convention by which REST requests can be combined, to receive back a single payload containing all the responses needed? To use the Stack Exchange User page as an example, you probably would need to call at least these from the Stack Exchange API to build the page: - /users/{id} - /users/{id}/answers - /users/{id}/reputation - /users/{id}/tags - /users/{id}/questions - ...etc Could the provider of such an API allow you a single request to get all that data? Especially if other root types were involved, say you had to also request /revisions/{id} and /tags to build the page also for some reason. To be clear, I don't want to know if it's possible to provide such functionality in a web API -- I want to know if there is a standard or at least documented means of doing so.