Mobile Zone is brought to you in partnership with:

Max Katz heads Developer Relations for, a cloud-based mobile app platform. He loves trying out new and cool REST APIs in mobile apps. Max is the author of two books “Practical RichFaces” (Apress 2008, 2011), and is a frequent speaker at developer conferences. You can find out what Max is up to on his blog: and Twitter: @maxkatz. Max is a DZone MVB and is not an employee of DZone and has posted 90 posts at DZone. You can read more from them at their website. View Full User Profile

We the People API, Creating HTML5 Mobile App Over Lunch

  • submit to reddit

The United States Government is offering 100s of APIs as part of its Next.Data.Gov iteration. As I navigated the site I came across Government APIs page:


I always love trying new APIs and wanted to see what kind of API “We the People” provides. The API seemed to be pretty straight forward and next I figured let me try and build a mobile app that shows the petitions as well as details for each petition platform. I literally finished the app within 35 minutes or during my lunch.

Creating the pages

After creating a new app in, I designed the Petition page:

2013-07-17_1610Petition list page
  • A List component with a Label inside to display the petition name is used. 

Next is Details page:

detailsPetition details page
  • The Label at the top displays the petition name (only border is shown)
  • The Collapsible Block has three sections:
    • Details – petition texst
    • Signatures – signature threshold, signature cound, and signtaures needed
    • More Info – link to petition page

The last page is Settings (popup):

settingsSettings page
  • Allows to select how many petitions to show

Defining REST API services

Two services are used in this app:

  1. Service to get a list of all petitions
  2. Service to get petition details

The service to get all petitions:

service_petitionsPetitions API

The service has one request parameter to determine how many petitions to load:

service_pettion_requestPetition service request parameters

Service response:

service_responsePetition service response parameters

The other service is to load petition details:

service_detailsPetition details service
  • The {id} is the petition id which was selected

To learn more about We the People API.

Binding services and pages

Once we get all the petitions, we map the data returned to the page:

petition_mapping1Petition service to page mapping

On Details page we show information about a particular petition and thus get the petition id from local storage (it was stored when the petition was selected from the list). Request mapping is shown:

service_mapping_detailsMapping local storage variable to service request

The response mapping for Details page looks like this:

service_mapping2Petition details service mapping to page

Invoking the service

Once the service-page bindings are done, the last step is to invoke the service. For Petitions page, the service is invoked on ‘page load’ event:

petition_invokeInvoking service

For Details page, the service is also invoked on ‘page load’ event.

Testing the app

Testing is as simple as clicking the Test button:

testingTesting the app in browser

It’s as easy to test the app on the device by scanning the QR code.

Publishing the app comes with instance app hosting feature:

hostingHTML5 app hosting

Go ahead and try the app:

An app over lunch?


Gone are the days when you had to spend days downloading and configuring dev. tools. Gone are the days when you had to spend days downloading and configure software. With a cloud platform such you can quickly build a real HTML5 mobile app, connected to real API, and host the app.

Share on twitterShare on facebookShare on dzoneShare on printShare on emailShare on pdfonlineMore Sharing Services
Published at DZone with permission of Max Katz, author and DZone MVB. (source)

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)