Amazon at the Bookstore

Say you're browsing books at your favorite bookstore and want to know how much a book costs at Amazon. Amazon at the Bookstore, the app described here, lets you search Amazon by keyword or ISBN number, a
nd find the lowest price of the books you find. You can even scan a book's QR code to automatically trigger the search. Want to try it? Just scan the QR code to the right with your Android phone -->

Amazon at the Bookstore demonstrates how App Inventor can be used to create apps that talk to web services (APIs). It's a client app that gets data from a web service that already exists, specifically http://appinventoramazonlist.appspot.com. After stepping through this tutorial you'll be able to create your own custom client app for talking to Amazon.

For those of you that know some Python programming, or a Python programmer, you can also build your own App-Inventor-compliant web services, which can then be consumed by App Inventor clients. One way to start is to download the source code of
http://appinventoramazonlist.appspot.com and modify it to call the web service you want.

Creating the Amazon Client with App Inventor

The application has a simple user interface that allows keyword or ISBN to be entered, then lists the title, lowest new price, and a link to the details page at Amazon. It also makes use of the BarcodeScanner component so the user can scan an ISBN for the information.
Components

Here is how the app looks in the Component Designer after the necessary components are added:


The key non-visual component is TinyWebDB, which is found in the "not ready for prime time" drawer. When you drag this component into the app, you can set the Service URL for it. In this case, set the URL to http://appinventoramazonlist.appspot.com.

Designing the Behavior

You access App-Inventor-compliant web services using the TinyWebDB component and its GetValue operation. GetValue requires an argument tag that can be used to ask for particular data from a service. All services will return data in a particular format. http://appinventoramazonlist.appspot.com uses the following protocol:

 tag  value returned
 isbn: #########
 a list of one item containing the matching book
 any keywords
 a list of five items matching the keywords

The list returned is a list of books, with each item (book) being a list itself with the following items:

item 1: title
item 2: cost
item 3: isbn

Here are the blocks for the app:

Details on how they work to come...

The Amazon TinyWebDb Web Service
The App Inventor team provided the original tinywebdb web service (http://appinvtinywebdb.appspot.com/) as a model for other web services that can be "consumed" by Android clients using the TinyWebDB component. The service was implemented using Google's App Engine and the Python programming language. It doesn't call another web service, but instead allows you to store and retrieve persisten data.

The Amazon web service used in this demo,
http://appinventoramazonlist.appspot.com., was built by modifying the original web service so that it gets its data not from a database but from Amazon. You can download the source code for it here. The code won't work out of the box, you'll need to get an account with Amazon web services and plug your authentication keys in.

Challenge
  • App Inventor Designers: Beautify and extend the Amazon client app. Either start from scratch using the picture of the blocks above, or by uploading the App Inventor client source code into App Inventor (from My Projects choose More Actions | Upload Source)
  • Python Programmers: Extend the Amazon api below to allow for more complex interaction with Amazon.
The first attached file below is the App Inventor client source code. The second is the App Engine web service code.


ċ
AmazonBookstore.aia
(5k)
David Wolber,
Sep 7, 2015, 2:02 PM
ċ
BookstoreBrowser.zip
(5k)
David Wolber,
Jul 18, 2010, 6:03 PM
ċ
BookstoreBrowser2.apk
(1187k)
David Wolber,
Sep 27, 2011, 1:39 PM
ċ
aiamazonForDistribution.zip
(51k)
David Wolber,
Sep 7, 2015, 1:59 PM
ċ
amazontinywebdblistDistr.zip
(46k)
David Wolber,
Jul 20, 2010, 10:32 AM
Comments