Introducing the ALF, the AMEE Location Footprinter

With our new AMEE Labs app ALF – AMEE Location Footprinter, we’ve just made working out carbon footprints absurdly easy for 10 million more people with our latest mashup, using Foursquare’s API and AMEEconnect, our API for emissions calculations.

Click to visit ALF

At AMEE, there’s a fair few of us who are keen users of Foursquare, and some of us have built up a decent history of checkins over years of using the tool. Better yet, those lovely people at Foursquare have been nice enough to share access to this data over a really easy to use API.

AMEE is building the largest single store of data about greenhouse gas emissions on the planet, which we also provide access to over an API. As you’d imagine at a data-driven startup, we’re big fans of using APIs to help us see the world in new and interesting ways. 

Meet ALF

When we got a spare moment we started experimenting with Foursquare’s updated API and our own Appkit and produced AMEE Location Footprinter, or ALF as we’ve come to know him inside the team. ALF estimates the environmental impact of your travel habits. It makes some guesses about how you’ve travelled between venues in your checkin history and each week sends you an email providing a summary of the total footprint of your travel for the last seven days.

Why did we build this?

Apart from it being well… fun, the other reason for ALF is that transport is responsible for just over an eighth (13.5%) of all global greenhouse gas emissions, and we wanted to make that more visible. 

Of course, when you’re trying to make assumptions of travel based on Foursquare checkins you have to make a few comical assumptions about how people get around. So please bear in mind – this very much an experimental hack rather than a full featured app, and the reaction we had in mind is more along the lines of “oh, this is pretty cool, maybe we should look at how we travel after all”, rather than “Ah-ha! – this tool is all we need to travel sustainably from now on!”.

How we built this

This part will get pretty technical. Feel free to skip to to the end of this post if you’re not too technically inclined.

ALF is a Ruby on Rails 3 app, that uses a couple of libraries to make talking to Foursquare and AMEE’s API’s relatively trivial.

Talking to Foursquare

Once you get your head around using Oauth2, Foursquare new API is a joy to work with. Their explorer makes working out what to expect back from the API easy. 

If I’m signed into foursquare in my browser, I can just type in various urls in the explorer, and I’ll get back examples of the JSON responses. It follows the “show, don’t tell” principle, by showing me what I’ll get back if I try hitting an API end point, instead of telling me to head off and trawl through documentation. This is incredibly handy when coming to a new API.

Once we were more familiar with the API, we found that using the quimby gem made working with it a real pleasure. This let us treat the entire foursquare API like an object, calling simple methods like “foursquare_user.name”, instead of needing to think about API calls constantly.

Talking to AMEE 

Once we had this, we were able to then use the auto generated Ruby code for us, stored in the helpful tab marked “Code”, to drop into our app. 

In this case however, we used the AMEE Appkit, a library that allows for deeper integration into the platform, so we don’t need to think in terms of individual API calls, but think of AMEE as an integral part of the app. 

This has the same effect as using a software library like quimby did for foursquare – it stops us having to think about making separate GET or POSTs to API endpoints whenever we want to interact with the platform, and think instead in terms of calculating footprints.

However, using appkit is a series of blog posts in it’s own right, so I’ll leave it here.

We can always refine these calculations later with more detail, to take into account make, model, year, right down to whether the air-con is switched on the car or not.

Once we had this, we were able to then use the auto generated Ruby code for us, stored in the helpful tab marked “Code”, to drop into our app. 

In this case however, we used the AMEE Appkit, a library that allows for deeper integration into the platform, so we don’t need to think in terms of individual API calls, but think of AMEE as an integral part of the app. 

This has the same effect as using a software library like Quimby did for foursquare – it stops us having to think about making separate GET or POSTs to API endpoints whenever we want to interact with the platform, and think instead in terms of calculating footprints. 

Like it? Help us make it better!

If you do use it, contact us as we’d love to hear form you to see what you think of it, and what features you’d like to see. This was built more as an experiment than anything else, so there will be rough edges.

If you’re technically inclined, the source code for ALF is on github, feature-requests, patches and pull requests would make the dev team very, very happy – don’t be shy!

Back to AMEE Blog