Skip to content

kippt/django-api-boilerplate

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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)

Releases

No releases published

Packages

No packages published

Languages