Python Interface to the HipChat JSON API
One of the many modern challenges to scaling a business is keeping employee accounts consistent. Traditionally, businesses would use a LDAP or Active Directory server and make all their tools plug in to those services. When someone was hired, they would receive a single user account that worked everywhere. At Tagged, we wrote a tool called SUMP: Simple User Management Portal. SUMP hooks into all the systems that we use, such as Google Apps for Businesses, our LDAP server and Hipchat, which we use for group chat.
There were already a few libraries available to access HipChat’s API but none had the user creation features we needed, and we preferred Python. So, we decided to roll our own library and release it as Open Source. Since many organizations have their own tool like SUMP, often written in Python, we figured this has a high value for other groups. Writing these libraries can be so simple that it’s easy for many people to create their own implementation. By releasing it as Open Source, we benefit because it pushes others to use the same HipChat API. This causes HipChat to maintain it for all their customers, and not just for us, so we don’t need to worry that SUMP might stop working one day. We also get the added benefit of possible outside contributors.
When we wrote this code, we decided to make it as Pythonic as possible. The HipChat API returned JSON objects, which are more like dictionary data types, but it was clear there were distinct data objects. Every API call gets wrapped into a typed class. Rather than building up JSON objects, function parameters are converted automatically so the library has a very object-oriented feel. Finally, there are some sample command line tools in the ‘commands.py’ file to demonstrate some common use cases for the package.
While the library is simple, it’s designed with a couple abstractions to make it extensible. Behind the scenes is a base class HipChatObject and a partially applied call_hipchat function for accessing any arbitrary API function. This makes it possible for other developers to add features to the library very rapidly when HipChat introduces new functionality.
The code is available on both GitHub and Gitorious and there have already been some pull requests over Gitorious. It’s just a small contribution, but along with other projects like the Node.js Memcached Library – we’re paving the way for Tagged to do even more Open Source contributions in the future.
Yaakov Nemoy is a Systems Administrator at Tagged and you can follow him on Twitter and on Google+.


