Quickly expose your models to a JSON or XML API, authenticated via HTTP or OAuth.
About Bambu API¶
This package allows you to easily expose Django models to RESTful endpoints which can send data in XML or JSON format.
About Bambu Tools 2.0¶
This is part of a toolset called Bambu Tools. It’s being moved from a
bambu to its own ‘root-level’ package, along with all
the other tools in the set. If you’re upgrading from a version prior to
2.0, please make sure to update your code to use
Install the package via Pip:
pip install bambu-api
Add it to your
INSTALLED_APPS = ( ... 'bambu_api' )
bambu_api.urls to your URLconf:
urlpatterns = patterns('', ... url(r'^', include('bambu_api.urls')), )
The prefix should be kept blank, as the package exposes two main URL
/api/, wherein the RESTful endpoints live, and
where auto-generated documentation for each endpoint is found.
You define API endpoints like Django admins, and register them in a similar way.
Teka the Django ‘polls’ app as an example. Within the polls directory, you’d create a file called api.py. A simple API endpoint would be defined like this:
from bambu_api import ModelAPI, site from myproject.polls.models import Question class QuestionAPI(ModelAPI): pass site.register(Question, QuestionAPI)
This registers the
QuestionAPI endpoint for the
The endpoint is then accessible at