Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Tapioca is small and flexible micro-framework on top of Tornado to enable a easier way to create RESTful API's.
Python
branch: master

This branch is 100 commits behind globocom:master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
tapioca
tests
.gitignore
LICENSE
Makefile
README.mkd
requirements.txt
setup.py

README.mkd

Tapioca

Tapioca is a small and flexible micro-framework on top of Tornado. It provides a simpler way to create RESTful API's.

Why Tapioca?

Create APIs using Tornado is easy, but Tapioca makes it even easier. Tapioca provides common behaviour to manage resources as close as possible to the definition of your RESTful API.

Tapioca also provides many different encoders enabling your resource to be easily serialized in different formats.

It´s incredibly easy to respond in a format that your API clients can understand.

Doesn't matter if they are a machine or a human being.

Tapioca gives you an automatic console interface to your API. This way it can be used as both the documentation and testing interface by your API clients.

Usage

...

Extending

You can easily make your API speak a new "language".

Implementing your own encoder can be achieved in a few steps:

  • Create a python class that inherits from tapioca.Encoder;
  • Override both encode and decode methods;
  • Provide some metadata about your new encoder by specifying its mimetype and extension.

Below is a example of an encoder that enables responses as yaml data.

import yaml

from tapioca import Encoder

class YamlEncoder(Encoder):
    mimetype = 'text/yaml'
    extension = 'yaml'

    def encode(self, data):
        return yaml.dump(data)

    def decode(self, data):
        return yaml.load(data)

Using this encoder in your resources is as easy as including it in the encoders attribute in the respective ResourceHandlers.

from tapioca import ResourceHandler

class CommentsResource(ResourceHandler):
    encoders = ResourceHandler.encoders + (YamlEncoder,)

    # ...

Now you can access your route and see it working:

$ curl -X GET http://localhost:8000/comments.yaml

Contributing

To contribute with the Tapioca you can just fork the project, implement all the changes you need and then send us a pull request. It's important to make consistents pull request's. This means that every new feature should be in a separated pull request, in order to give us the possibility to review them separately (comments and feedback as well). We are open to suggestions and to discuss all your ideas.

License

Tapioca is licensed under the MIT License:

The MIT License

Copyright (c) 2012 globo.com lambda@corp.globo.com

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Something went wrong with that request. Please try again.