Sunday, November 27, 2011

The Multiple Google API's

I started the next task of my project, pulling video feeds from YouTube. I was first presented with a real easy interface and then later on, I was massacred. It turns out there's GData Java Client (w/o Android support) and Google API Java Client (With Android Support). Ridiculous difference between the two: GData API (obvious winner) - but with its drawback. 


GData API is no longer being actively developed, but will continue to be supported. Extremely easy interface, much like
YouTubeService service = new YouTubeService(app_name);
VideoFeed feed = service.getFeed(requestUrl);
and Bam! A whole List<VideoEntry> at your disposal.


Google API is now being developed due to its better flexibility with JSON responses and multiple services using the JSON response. It provides a smaller memory footprint because you could use partial JSON responses. But you have to make your own XML Data Models.
Read on...

I needed to pull some videos off of YouTube and to test it, I wrote the code for a regular desktop Java app. The GData API makes it real easy to send service specific requests, like Picasa, YouTube, Buzz, and any other Google service. Really convenient but you can't develop it for mobile apps. You'll get a compiler error saying that you're trying to build a core Java library or some weird Runtime Exception saying class not found. Then I did some more research and found out that I had to use Google API Java Client.


Here's the difference: they say that the old GData API had service specific classes and interfaces that made it real easy to use, but made it hard to port to a JSON format (I have a very minimal understanding of what JSON is apart from that its a specially formatted response that XML parsers can read and load into classes). So to fix this issue, they just made an entirely new library where you have to set up your XML Data Model classes. When I read that on the project website, I was like WTF is an XML Data Model Class!??!?!?!!?! It's a little daunting at first, but I'll give you examples on the next post. 


I made this post to briefly explain the differences between both API's and the fact that the Google API Java Client supports Android and the other one doesn't.

No comments:

Post a Comment