Theirs been a few attempts at creating a standardised format, one is:

http://labs.omniti.com/labs/jsend

with a gem available:

https://github.com/utahstreetlabs/jsend-rails

Implemented on a recent project here and it seems to be quite flexible.

Samuel Richardson
www.richardson.co.nz | 0405 472 748


On Fri, Jun 1, 2012 at 9:07 AM, Julio Cesar Ody <[email protected]> wrote:

> > We still return per_page in our API calls as we have limits on what
> > the client can request. So although a client my request a page size of
> > 200 for load management and performance reasons we may only accept
> > values of 50 (for example).
>
> I quote myself:
>
> > and in which case, it should accept a range value, or two values, one
> for range beginning and range end. The
> > gist here being that some clients might find it suitable to fetch more,
> others less, and your API should simply
> > let those clients decide that. Probably up to a certain number of posts,
> of course.
>
> As for what Ivan suggested, working backwards from what you'll need
> works, yes, and probably if said API will be consumed first and
> foremost by JS, then go for that and make changes as you need them
> should mobiles or whatever come next. I assume you have a budget/time,
> so that helps that.
>
> Oh and about "semantics" in APIs, the fact is an array is a structure
> where the length equals the number of entities it carries. So turning
> a collection into an object just so it can carry metadata which can
> obviously be extracted from this characteristic of the collection
> doesn't make anything more semantic, but just repetitive.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ruby or Rails Oceania" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/rails-oceania?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
or Rails Oceania" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rails-oceania?hl=en.

Reply via email to