Skip to main content
Help us improve PyPI by participating in user testing. All experience levels needed!

A lightweight REST miniframework for Python.

Project description

A lightweight REST miniframework for Python.

Documentation is at

Works great with Django, Flask, Pyramid, Tornado & Itty, but should be useful for many other Python web frameworks. Based on the lessons learned from Tastypie & other REST libraries.


  • Small, fast codebase
  • JSON output by default, but overridable
  • RESTful
  • Python 3.2+ (with shims to make broke-ass Python 2.6+ work)
  • Django 1.8+
  • Flexible


(Things that will never be added…)

  • Automatic ORM integration
  • Authorization (per-object or not)
  • Extensive filtering options
  • XML output (though you can implement your own)
  • Metaclasses
  • Mixins


Quite simply, I care about creating flexible & RESTFul APIs. In building Tastypie, I tried to create something extremely complete & comprehensive. The result was writing a lot of hook methods (for easy extensibility) & a lot of (perceived) bloat, as I tried to accommodate for everything people might want/need in a flexible/overridable manner.

But in reality, all I really ever personally want are the RESTful verbs, JSON serialization & the ability of override behavior.

This one is written for me, but maybe it’s useful to you.


Rather than try to build something that automatically does the typically correct thing within each of the views, it’s up to you to implement the bodies of various HTTP methods.

Example code:

# posts/
from django.contrib.auth.models import User

from import DjangoResource
from restless.preparers import FieldsPreparer

from posts.models import Post

class PostResource(DjangoResource):
    # Controls what data is included in the serialized output.
    preparer = FieldsPreparer(fields={
        'id': 'id',
        'title': 'title',
        'author': 'user.username',
        'body': 'content',
        'posted_on': 'posted_on',

    # GET /
    def list(self):
        return Post.objects.all()

    # GET /pk/
    def detail(self, pk):
        return Post.objects.get(id=pk)

    # POST /
    def create(self):
        return Post.objects.create(

    # PUT /pk/
    def update(self, pk):
            post = Post.objects.get(id=pk)
        except Post.DoesNotExist:
            post = Post()

        post.title =['title']
        post.user = User.objects.get(['author'])
        post.content =['body']
        return post

    # DELETE /pk/
    def delete(self, pk):

Hooking it up:

# api/
from django.conf.urls.default import url, include

from posts.api import PostResource

urlpatterns = [
    # The usual suspects, then...

    url(r'^api/posts/', include(PostResource.urls())),



Running the Tests

The test suite uses tox for simultaneous support of multiple versions of both Python and Django. The current versions of Python supported are:

  • CPython 2.7
  • CPython 3.3
  • CPython 3.4
  • CPython 3.5
  • CPython 3.6
  • PyPy (Python 2.7)

You just need to install the Python interpreters above and the tox package (available via pip), then run the tox command.

Project details

Release history Release notifications

This version
History Node


History Node


History Node


History Node


History Node


History Node


History Node


History Node


History Node


History Node


History Node


History Node


History Node


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help File type Python version Upload date
restless-2.1.1.tar.gz (43.6 kB) Copy SHA256 hash SHA256 Source None Jun 1, 2017

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging CloudAMQP CloudAMQP RabbitMQ AWS AWS Cloud computing Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page