Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (
Help us improve Python packaging - Donate today!

RESTful endpoints for aoihttp that bind directly to a model

Project Description

aiohttp_rest makes it easy to create RESTful aiohttp endpoints that bind directly to models with minimal modification.


Create your model:

class Person:
    def __init__(self, name, age): = name
        self.age = age

Create an aiohttp application that makes use of a aiohttp_rest.RestResource:

from aiohttp.web import Application, run_app
from aiohttp_rest import RestResource

from person import Person

people = {}

app = Application()
person_resource = RestResource('people', people, Person, ('name', 'age'), 'name')


Interact with the API:

http POST localhost:8000/people name=andrew age=24
http localhost:8000/people/andrew
http PUT localhost:8000/people/andrew/age age=25
http DELETE localhost:8000/people/andrew

Several things are required by the RestResource to make all this work:

  • A name for the resource, this will form the base of the URL.
  • A factory method for the model, as seen above, this can simply be the init method for the model or something more complex.
  • A collection to store the models, this should be a dict-like object.
  • A list of properties to expose to the API.
  • A property to treat as the id for the collection. In the above example we used the name as the id, so that’s what we used in our URLs to refer to a specific instance in the collection.


git clone
cd aiohttp_rest
python install


pip install -r build-requirements.txt
py.test tests



Release History

Release History

This version
History Node


Download Files

Download Files

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

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
aiohttp-rest-0.1.0.tar.gz (6.8 kB) Copy SHA256 Checksum SHA256 Source Apr 2, 2016

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting