Legos for your Django API
Python
Failed to load latest commit information.
api_boilerplate Patch session request with CSRF token May 24, 2013
docs Docs folder Mar 30, 2013
example Comments Mar 31, 2013
.gitignore Hide docs folder for now Apr 1, 2013
AUTHORS Initial commit. Mar 30, 2013
LICENSE Initial commit. Mar 31, 2013
README.md Added note about /api/ Apr 1, 2013
setup.py setup.py May 8, 2013

README.md

django-api-boilerplate

This project is meant to provide the basics for people to create well behaving APIs for Django projects. It's not an app for automatically creating APIs like tastypie or piston. Instead it provides the building blocks which you can use to roll out your own RESTful API fast with Django's Class based views. This provides:

  • Class based API views and decorators
  • API Responses for different HTTP codes
  • Model pagination
  • Authentication middlewares:
    • Django cookies
    • HTTP Basic
    • API Key

Most of this code is extracted from Kippt's API (documentation on Github). It's designed to be as easy as possible to consume, mainly meaning simple authentication (browser session) and JSON output. This makes API debugging extremely easy with Chrome's JSONView and Postman extensions. You should also be using requests.

Some of the code in this project is influenced by or forked from awesome django-tastypie. HTTP responses are created based on work of Leah Culver and Eric Florenzano.

Settings

API_KEY_MODEL

Default: api_boilerplate.models.ApiKey

API_LIMIT_PER_PAGE

Default: 20

API_AUTH_CASE_INSENSITIVE

Default: False

API_AUTH_EMAIL_AS_USERNAME

Default: False

API_REQUEST_JSON

Default: True

Common best practices

  • Use api() method for resource Models to return a Python object. Responses will convert that into JSON. This will make caching easier as well.

Todo

  • Docs all the things
  • Better name
  • Test all the things
  • Separation for /api/ url (usually the redirect for docs)
  • JSONP and errors
    • Better way of handling error messages
    • Have a separate field for error messages in JSONP response
  • Rate limiting (Cache/Redis based)