Mobile - Web - Media
Tuesday, Jan 10, 2006 11:58:25 AM
Web Service Mashup: Last.fm and Amazon.com
Hey, Happy New Years everyone! As usual, my wife and I had a mellow celebration - we aren't big partiers or go for the massive crowds, but we brought in the New Year with a toast of champagne and a kiss.
Resolutions? No, sorry - I've never been one to create New Years resolutions. I can completely understand why people do, and that the new year psychologically helps people move forward - as if they are drawing from the concept of "starting over." Ideally, if you want to be a progressive person, and if you want to discover your true potential - you must entertain the idea of resolutions all year long. We are delicate machines needing little tweaks here and there - if you only get a goal realignment once a year, your wasting fuel, missing opportunities and not meeting your potential.
Now onto the New Year... so, what's currently on my plate? My first attempt at a Web Mashup :) What's a Web Mashup? At a bare minimum, it's when you take two or more Web services and use them together to create something else or new. A Web Service could be thought of as a Web site's data and logic without the actual site. For example - you could go to a weather site and view the data as they present it on their site, or, you could connect to the weather site's Web services, and request the data you want, then display it on your site or in your application. If this is new to you, welcome to the Read/Write Web - the Programmable Web - Web 2.0 - etc. :)
I have a few goals and plans for using Web Services, and since a few of those ideas pertain to Amazon.com, I started there. I'm going to talk about two projects below, so before I continue, I'll list the projects.
- Similar Artists - My plan was to pass a genre name and return a selection of CDs/Artists associated to that genre, or allow people to search for commercial artists they know, and return a selection of related artists. This is for a potential project I'm working on where I'm looking to connect music fans to ArtistServer.com artists though the artists people already know and listen to. One of the hardest parts of getting listens as an independent artist, is being found - and one way to help people find these artists is by allowing them to select who they do know and like, and have that selection connect to ArtistServer and display similar artists. This is basically one of the foundations of learning - you take things you already know, you discover something, you mentally assoicate it to what you already know, then integrate the new knowledge or experience into your memory. This is currently just an experiment, but it may get launched as another 'satellite site' for ArtistServer. Possibly under the name GenreTree.com.
What is a "satellite site?" It's a site you create and manage that serves to transmit traffic to your central site. Ideally, a satellite site will have some value and not be spam/fluff - but it's main focus is to sit out there and function as an advertisement for your main business. I have no idea if this is a term currently in use, but I believe it to be a good strategy that you could apply to all kinds of sites.
- Music Banner Ads - This second project is where Last.fm comes in. Here I was looking to create a system where anyone who uses Last.fm could first join the Associate program at Amazon.com, then come to the site I have running and have the ability to generate dynamic music banner ads based on what they listen to. Last.fm already provides an excellent means to list your "top artists" and "recently listened songs" on your site, but it lacks the means to generate revenue. If you are going to advertise what you listen to, why not earn revenue from it? If you look at how Last.fm works, they have a page setup for every artist in their system, and if possible, they have the artist's CDs listed with amazon.com their Associate ID attached. So, if Last.fm can use your data to drive affiliate sales through Amazon, so should you!
I first connected into Amazon, and that was working great - so I clicked over to Last.fm and began working on consuming their XML feeds. Ten minutes into it, Last.fm went offline for the next 6-8hrs. Perfect timing eh? The next morning I dive into it again - Last.fm is back online and in a few hours, I finished the code to consume seven of their offered XML feeds (along with caching them locally for speed).
I had already achieved the goal for the first project, the only thing I needed to do was adjust the formatting and build a site around the idea. The second project is where I ran into some trouble. The code was functioning just fine, the trouble was the results coming back from Amazon. In order to minimize the number of requests to Amazon (you are allowed 1 request per second per IP address) I was using their "TextStream" search and passing the artists or artists and albums as a string of text. It seems the searching functionality of Amazon's TextStream isn't as great as I was thinking it would be. The results it returned usually only found 1 out of 6 artists I would pass it. I tried passing them as a comma list, in quotes, as one text string, and while the results did vary - they never improved. As a check, I would visit Amazon and search for each item separately, and return results.
With the TextStream search being nearly useless, I've concluded that the only way I can reach the level of quality I'm expecting, is to search for each entry (artist or artist/album combo) individually. Unfortunately, that doesn't scale very well when done in real-time. The only way that would work is to distribute the requests to Amazon to the actual sites that will display the end results. I'm not sure that can work though, since the XML file needs to be saved (cached) so the banner ad can be built from it. Another method is obviously needed where I would store all the data locally on my server.
I'm now thinking that the only way to offer this as a service, would be to consume the users Last.fm XML files on a daily basis, then extract any new artists and store them in a database table. Then hit Amazon's Web services with that list, and return the results back to another table. With Amazon's data now cached on a daily basis, my application could then consume Last.fm Web services for a user, query the local database, then generate the music banner ad with their Associate ID. Then I'd need a scheduled task to run each day to harvest new artists from the Last.fm profiles of the users of this service, store the results, and repopulate the Amazon table based on the new collection of artists in the Last.fm table. With this solution, the application/service could scale and provide nearly perfect output for the banner ads.
If Amazon's TextStream search was more rocking, I could launch the service in the next week, but since it retuns things like "Carole King" when I pass it "King Tubby," the service would suck, even if it was free - which it will be. Unfortunately, I'm not sure when I can dedicate the time to building a version that would store all the artists and albums from the users profiles, in addition to requesting and storing the data from Amazon. That's going to take a lot more time to develop and test. Bummer.
But all is not lost :), my work this last weekend on Web services taught me more about the technologies being used, about the parsing of XML files, how to build a dynamic query from XML contents, how to consume and cache an external XML file, and I've started to understand the Amazon Web service platform.
While I'm sad that I didn't succeed in launching the Music Banner Ad service, I am quite excited about the world of Web services and I'm sure that after I do some additional work with some other site's APIs, I'll become more motivated about the creation of ArtistServer.com's API - which is in the plans - but not until the end of the year.
If you are interested in my Music Banner Ad idea, or if you have any ideas about it, please feel free to comment or send me an email to discuss.
- ADD TO: