Copyright © 2012 Tom Coote. All Rights Reserved. Powered by WordPress themed by bavotasan.com.
It has been a pretty rainy weekend so I’ve decided to do some Python programming and have come up with a set of tools to help build API’s in django.
I know there are a few libraries already available for building API’s in django (I’ve used and contributed to some of them) but since django 1.3 was released with the class based generic views then a lot of the functionality needed to create API’s is already in the framework. So I decided to just build a few extra things to make API’s easy in django by using the framework for most of the heavy lifting.
I’ve made the code available on GitHub. Here are the features in a nut shell;
- A new generic class view called APIView which provides a mini framework for supporting different data formats for an API and providing some common API responses.
- A throttling decorator to limit API calls per user.
- Support for base64 http authentication.
I’ve put basic support in for JSON requests and responses. The code acts as a good basis for a complete API in django and allows an easy way to extend it for new data formats. It makes good use of POST, GET, PUT and DELETE request methods.
View the repository on GitHub. I would be interested to know how anyone gets on using it and if anyone adds in support for different data formats.

