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 http://www.slideshare.net/tarequeh/restful-apis-promises-lies

Updates Below:


14.44

“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

14.41

Question Time…

14.40

Can view the modified django-piston at http://github.com/pbs-education/django-piston

14.38

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

14.34

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

14.29

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

example.org/api/v1.0/some_url

14.28

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

14.26

Envelope your responses with status, errors and data.

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

14.24

Resources from APIs != your Django models

14.22

Tareque talking extremely quickly, covering the basics of RESTful APIs

14.20

Here we go, Tareque taking the stage.