3

I'm not trying to start a religious war, but I personally really don't like api version information in the URL of a resource. I think the best way to do it is via the Accept header of the resource or adding a ?version=2 to the query string. If you are curious about this topic. There are a number of good (an passionate) posts on StackOverflow on the topic. Here is a good thread here. Also, IMHO, a good blog post here by Steve Klabnik. Again, these are just my perferences, and I'm not trying to create a thread on this topic (again).

I'm currently looking for a Django package to help with creating a RESTful API. After some reading, it seems like TastyPie has most of what I want/need and is well supported (and has really good docs). And I'm just wondering if there is a way to implement a different versioning scheme? Has anyone else out there done this? Is there another package that might work more the way I want?

Community
  • 1
  • 1
David S
  • 12,967
  • 12
  • 55
  • 93
  • I think you'll be able to do that with Tastypie. I have recently implemented the ?filter= support to avoid putting attributes in the query string directly. Also I've first implemented my API using Piston but then moved on to Tastypie and I like it a whole lot better. It's much more robust and flexible. So my personal inclination is that Tastypie is currently the best tool for building RESTful APIs with Django out there (but I don't want to start a war either ;) ). – kgr Mar 02 '12 at 18:20

1 Answers1

4

Yes, you can use Accept headers or any other method to version your API, and do this in a way that is not specific to whatever Django API package you are using. One easy way to do this is to add some middleware to check for the headers on relevant requests and then load the appropriate URL conf depending on the version specified.

There are several simple apps on github that use URL routing middleware that you can customize to meet your needs.

Also, Tastypie is amazing and I highly recommend it over Piston after using both.

Spike
  • 5,040
  • 5
  • 32
  • 47