Building Better Web Services With Django (Part 1)

Andrew Wilkinson

Building a RESTful webservice is pretty straight-forward with Django, but in many cases you want to have both a human readable website and a machine readable api. A lot of websites solve this problem by using http://www.x.com as the human site, an api.x.com as the machine site. They also will typically have different structures to support the different usecases.

Unless your documentation is really excellent and the person writing the client to your service actually reads it building a client for the service is an error prone process. In an ideal world the developer would be able to browse the website and use the same urls in their client program. Fortunately HTTP has two headers which make it possible to do just that, Content-Type and Accept.

The Content-Type header describes the type of data that is included in the body of the HTTP request. Typically this will be values…

View original post 378 more words

Advertisements