Tuesday, 14 August 2012

Android - An open-source API for the Android Market

1. Introduction
The Android Market, now "Play", is getting bigger and bigger. The result is there are too many applications that couldn't be easily discovered by all the users. It could be a good idea to have an application which matches our interests and recommend applications that could be interested for us.

The problem behind is there is not an official API which the developers can use to access the Android Market. The good news is there is an open-source API, which seems to work.


This API offers methods to search an App by name, to get the comments, to get the screencasts and even the icon of a specific application.

This post will demonstrate how to install a ruby wrapper over this project, which allow the users to use this API from the terminal. The unique problem is that not all the functions has been ported.

2. Installation
2.1 Install the jRuby
Actually the stable version of jRuby is 1.6.7.2, which could be found here:
Download the file depending on your Operation System and install it. In my case I have install it in a Mac OS, which the installation process was open the file and press several time "Next".

2.2 Install json-jruby
The json-jruby gem must be downloaded, even when the result has to be in XML format.
2.2.1 Download the last json-jruby file from:
2.2.2 Open the terminal
2.2.3 Go to the folder where the file has been downloaded
2.2.4 Type the follow command to install it:

sudo gem install json-jruby

2.2.5 The terminal will ask for the password of your user. Enter it.

2.3 Install Supermarket
The project supermarket is the Android Market API Ruby Wrapper project created by jberkel which could be found here:
2.3.1 Open the terminal
2.3.2 Download the project using git

git clone https://github.com/jberkel/supermarket.git

2.3.3 Go to the folder where the project is
2.3.4 Type the follow command to install it

sudo jruby -S gem install supermarket

2.3.5 The terminal will ask for the password of your user. Enter it.

2.4 Install jsonpretty (Optional)
Json Pretty is a program which by give a json string, it format the string and returns a legible output. Because the result from Supermarket could be quite hard to read, it is recommendable to install it.
2.4.1 Open the terminal
2.4.2 Download the project using git. Type the follow command in the terminal:

git clone https://github.com/nicksieger/jsonpretty.git

2.4.3 Go to the folder where the project is
2.4.4 Install Json Pretty using gem. Type the follow command in the terminal:

sudo gem install jsonpretty

2.3.5 The terminal will ask for the password of your user. Enter it.

No comments:

Post a Comment