Search the Bike Index using @IsItStolen on Twitter

A Twitter response from @IsItStolen

I made a Twitter bot! That's right, if you tweet bike serial numbers @IsItStolen, it will respond to you with a short description of bikes matching that serial number on the Bike Index along with their stolen status.

When Bike Index asked me to write a Twitter bot, I wasn't quite sure what I was getting into. I've always been a believer in open-source software, but I had never contributed any code to a project let alone created my own. As you may know, the Bike Index itself is open source, and you can star us on GitHub, fork, and add funtionality to your heart's content. Submit a pull request, and we'll add your features to the site! Luckily, the internet is an awesome place that is full of resources for people who want to learn what all of this means.

Since the Bike Index is written in the Ruby programming language we decided I should also use Ruby to create the bot. My development required me to learn three things: Ruby, the Twitter API (application programing interface. The way that computers can talk to Twitter instead of going to the home page), and the Bike API. There are a ton of Ruby tutorials, books, and reference guides online, so I started there. Also, you rarely go wrong with google results pointing to StackOverflow.

A great thing about Ruby is that there are lots of open-source libraries (called gems in the cutesy language of Ruby) available to extend the language to make it quick and easy to perform common tasks. It just so happens that querying the Twitter API is something a lot of people want to do in Ruby, so there is a gem that makes it a snap. There's no gem for the Bike Index (yet! but you could make one…) so for my application I used another couple of gems that make it easy to grab web pages (like the pages from the Bike Index API) and access the JSON results they provide in my program. I rolled it all up together and I'm now sending real live tweets.

Using the Bike API you have access to the entire database of bikes. You can perform a general search, access specific serial numbers, look up manufacturer information, add and edit bikes. Everything you can do on the web interface can be done through the API. So go ahead, write a form to embed bike data into your website, or a custom app to register bikes for your organization.