[thelist] RESTful APIs and iPad app at odds

Bill Moseley moseley at hank.org
Mon Jan 30 17:30:22 CST 2012

Looking for a little feedback from your experience on building a mobile app
and a new API.

I'm working on a new API for an existing application.  I'd like to adhere
to RESTful principles as much as possible, which in my case means simply to
try and be stateless, have URLs be nouns that represent resources (objects,
that may or may not map directly to a real resource like a row in a
database), use HTTP methods for verbs, provide caching headers in
responses, and to return URLs instead of just IDs.

Although the goal is to build a generic API that can be used by many types
of consumers, the first consumer will be for an iPad app.  And for mobile
apps it's best to transfer only the data needed, and in as few requests as

The RESTful API tends to have very discrete methods -- that is a given URL
will represent a discrete object -- so if you have to update a number of
them that may may many requests.

The other "at odds" principle is returning URLs instead of IDs.   If a URL
returns a collection of items, each with a URL that only contains a
different ID in the URL's path then there's some "wasted" bytes that are

I guess one could argue that the data returned for and iPad app request
might be a separate representation of the same object -- just like the same
object could be represented in JSON or XML -- and a request can say "Don't
return URLs, but return a compact list of IDs".

Anyone have any suggestions or insight about how to make REST and a mobile
app live together?  What have you done with your APIs used for mobile apps?

Or is this too much premature optimization?

Of course, if fewer requests and more compact responses are good for mobile
apps I'm not sure why they would not be good for other consumers, too.  If
I need to return 100 items in a collection and each item has a very long
URL with only a difference in ID should I come up with a scheme where I,
for example, return a URL as a sprintf string and then a list of IDs that
the client can sprintf() into the URL pattern?


Bill Moseley
moseley at hank.org

More information about the thelist mailing list