Android Marketplace APIs

Google known for releasing API for every service it offers has still not opened up their marketplace for the developers. There is no official API to access the marketplace and execute a search. But I came across this interesting project that uses the protobuf (The protocol that Google uses for almost all structured data communication).

http://code.google.com/p/android-market-api/

This is a Java implementation of the unofficial marketplace APIs and the site also has links to projects on other languages such as Ruby and PHP. Since this is an unofficial API there are many glitches for instance you cannot search beyond the 500th app details if your search query returns more than 500 results.

Searching by keyword

String query = "india";

AppsRequest appsRequest = AppsRequest.newBuilder()
.setQuery(query)
.setStartIndex(0).setEntriesCount(10)
.setWithExtendedInfo(true)
.build();

session.append(appsRequest, new Callback<AppsResponse>() {
public void onResult(ResponseContext context, AppsResponse response) {
                    //Process the response here
List<App> list =     appsResponse.getAppList();
int count = appsResponse.getAppCount();
for (int i = 0; i< count; i++)
{
App app = list.get(i);
System.out.println(" App Title is ::  "+app.getTitle() +"  App  Price:: "+app.getPrice()  +" App  Rating :: "+app.getRating()  +" App  Ratings Count :: "+app.getRatingsCount());
}
}
});

You can query apps based on the Package Name as well as publisher name.
Search By Package Name
String query = “pname:<package name>”

eg: String query = “pname:com.vkslabs.buybooks”;

Search By Publisher
String query = “pub:<publisher name>”;

eg: String query = “pub:vkslabs”;

Troubleshooting
If the search API works for keyword based search but not for package name or publisher name search then it might be due to the invalid Android ID. You need to set a valid Android ID for the API to work properly.

How to get a valid Android ID?

  • Install the application “Android System Info” from Marketplace and launch the app.
  • Goto Menu -> More -> Gtalk Service Monitor
  • Find the line aid:<Android ID value> (this is usually the second line in the screen)
  • Copy the value and set it as the Android ID in the MarketSession using the API

session.getContext().setAndroidId(“XXXXXXXXXX”);

1567 Total Views 1 Views Today