Mobile API Requests with JSON

Most mobile applications communicate with the internet. Some draw large amounts of their content from a stream, e.g. The Daily. Games communicate scores, twitter and facebook make API calls to pull your personalized information. It is hard to find a complex, compelling application that does not send HTTP requests.

Developers need to be conscious of how they make requests in order to minimize the impact on the device. Using the antenna consumes battery. Data transfers slower over cell towers than a broadband internet connection. Users are charged for transferring data. In this post I want to analyze how formatting the transferred data can influence performance.

I am currently working on a content-driven mobile application that needs to pull a lot of information across the network. One API request transferred over 1MB of XML. Through a little bit of research, we found that the service had the ability to return JSON instead. By switching to using JSON, the same request was under 512KB. We obtained the same information for half of the strain on the user’s battery. Not every request will see such dramatic differences between XML and JSON, but JSON is a very succinct encoding for data. Whenever possible, seek to find ways to decrease the size of HTTP requests. Your users will experience less latency, longer battery lives, and be charged less; all of which create happier users.

This entry was posted in Mobile. Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.

One Comment

  1. Shawn Anderson
    Posted March 10, 2011 at 11:08 pm

    We used this idea on SideReel’s iOS application.

    In conjunction with the to_api gem and aggressive device-side caching.

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="" highlight="">