0 comments
work
29 Sep 2009

IM Group API

When One Black Bear took over the Subaru (and later Isuzu) account we went over just how bad their website was… Pretty much every bad practice you can imagine has been used on that site somewhere at some point in time. While this is still the case their is a glimmer of hope; the dealership sites.

IM Group asked us to take a look at the dealer websites and see what kind of package we can put together to replace the Portfolio rubbish they use now.

It’s not as glamourous as the main site, but a good, stable client base and an opportunity to show what can be done. I’ve covered the dealer sites themselves in a separate post this one is more techy and is focused on the technology that they use; the IM Group API

Goals

When coding the API I always had a few goals in mind:

Some areas are a bit more complicated than I would like, as access has to be limited and tracked, but on a whole I’m happy with it. Makes handling all the dealer sites much easier.

Data

The API itself sits on imwww.co.uk but you won’t be able to see it unless you have a valid authentication token. If you know one, you will find the API has data on pretty much everything Subaru does (Isuzu data isn’t in there yet). It covers

The news, events & offers are mostly just content, a few images and some dates (start, end etc). However, the car section contains lots of information. It tells you the colours every model is available in, every variation the model has, the prices, insurance details, features, dimensions, extensive range of photography and anything else you would ever want to know about a car (even how loud it is…).

Contents

The large amounts of data that are flying around meant that finding exact data you want could be tricky… So I made it simple by using a RESTful architecture.

If you want only the latest 5 news items; then just ask:

imwww.co.uk/news/limit/5

Just want a single offer you know the name of, thats easy:

imwww.co.uk/offers/details/555-campaign

Want to do something more complicated? How about paginating the results, so you want page 5, with 10 per page and everything running in reverse order.. Simple:

imwww.co.uk/events/page/5/per_page/10/order/date desc

How about fetch data for only a single model, like the impreza:

imwww.co.uk/cars/model/impreza

To much data in your results? Only need the real basics; then you need the minimal flag…

imwww.co.uk/cars/model/impreza/minimal

Instead of fetching everything, just returns the basics, like names & prices (depends on what you apply the flag to of course).

Formats for Everyone

Are you an XML fiend? a JSON lover? A PHP code monkey? The API supports them all, just change the file extension:

Practical Use?

Lots of them! At the moment the API is powering every new dealer website, the vehicle data on the main Subaru site, all up coming Isuzu dealer websites, dealer locators, news feeds and much more to come.

Push and Pull

With some of the systems mentioned above polling is of course the way to do it; as replicating databases all over the place would make things very messy very quickly. Instead services like dealership locators use pull queries to API urls to fetch data.

This isn’t really an option for something as complicated as a dealer website. How slow would a website be if everything on that page had to be fetched from an API call? Dealer sites make use of the push notification system.

If content is edited on the master API – say a price change on the Outback – then the API sends out a notification to registered sites that there has been an update.

The site picks up on this notification and has a look at what has changed. If the data is relevant to the site, it updates its information. Much nicer!

Installing a Dealer Site

As I mentioned above, the API only talks to registered sites. The site is registered with the API during its own install process; it sends off a little bit of data about itself and the API updates its records.

The rest of the install also queries the the API, so within a couple of minutes all the latest details for everything Subaru is setup for that dealer.

Speed

From nothing (not even a domain name) to a fully working (out of the box) dealer site takes about 40 mins, most of that is setting up a new branch on the repo, making google accounts (gmail, analytics, maps) and DNS, but thats still pretty fast!

The API itself is sitting on a small server, so to keep it going fast basic caching is used (the API wipes the relevant cache files on updates, of course).

As this is a monster of a post, I blogged about the actual dealer sites in another post

blog comments powered by Disqus