DjangoCon 2011 – RESTful APIs: Promises & Lies

After a slow set of lightning talks and an amazing Keynote from Brad Fitzpatrick the first talk of day 2 is about to start. This talk is delivered by Tareque Hossain on APIs.

Over the last few years RESTful APIs have become an integral part of many Django projects. But some of the fundamental questions still remain unanswered. How do you decouple resources from models, formatting from definitions, authorization from authentication? How should you define resources? How do you handle pagination? Deliver facets? Prevent abuse? Implement versioning? Let’s have a look.

You can view the slides at

Updates Below:


“What is the benefit of adding the file extension (.json, .xml, .yaml) vs an accept header?”

  • Visually available to the client
  • Usable as a complete URL
  • PBS found it was easier for end users to construct the URL


Question Time…


Can view the modified django-piston at


PBS modified django-piston to add pluggable envelopes, anonymous requests


Different tools to help you build your APIs in Django. django-piston, tastypie, dj-webmachine, django-rest-framework


Always version your API to make sure you can grow over time.


Need to think about the different formats your API supports. XML, JSON, JSONP? More formats == more testing and more support time.


Envelope your responses with status, errors and data.

    'status': 200,
    'errors': [],
    'data': {


Resources from APIs != your Django models


Tareque talking extremely quickly, covering the basics of RESTful APIs


Here we go, Tareque taking the stage.