Tapioca is a small and flexible micro-framework on top of Tornado. It provides a simpler way to create RESTful API's.
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.
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
- Override both
- Provide some metadata about your new encoder by specifying its
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
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
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.
Tapioca is licensed under the MIT License:
The MIT License
Copyright (c) 2012 globo.com email@example.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.