Skip to content

Framework providing REST JSON API to the Tornado web server

License

Notifications You must be signed in to change notification settings

ginking/tornado_jsonapi

 
 

Repository files navigation

Tornado_jsonapi

Build Status Coverage Status Requirements Status PyPi version Documentation Status GitHub License

Tornado_jsonapi is a Python 3.3+ library for creating JSON API (as per jsonapi.org specification) using Tornado web framework. It features

  • semi-automatic API generation using provided JSON schema of resource;
  • support for arbitrary data sources, including SQLAlchemy and PostgreSQL (via DBAPI2 support layer);
  • support for asynchronous data source operations;
  • strict jsonapi.org specification conformance.

Usage

import sqlite3
import tornado.ioloop
import tornado.web
import tornado_jsonapi.handlers
import tornado_jsonapi.resource

schema = {
    "title": "post",
    "properties": {
        "text":
        {
            "type": "string"
        },
        "author":
        {
            "type": "string"
        }
    }
}

res = tornado_jsonapi.resource.DBAPI2Resource(
    schema, sqlite3, sqlite3.connect(':memory:'))
res._create_table()

application = tornado.web.Application([
    (
        r"/api/posts/([^/]*)",
        tornado_jsonapi.handlers.APIHandler,
        dict(resource=res)
    )
])
application.listen(8888)
tornado.ioloop.IOLoop.current().start()

Installation

$ pip install tornado_jsonapi

Documentation

https://tornado_jsonapi.readthedocs.org

Roadmap

a.k.a. TODO

  • improve documentation 😔
  • automatic API doc generation based on JSON schema;
  • MongoDB/Motor support;
  • support for API testing.

License

This project is licensed under the MIT License.

About

Framework providing REST JSON API to the Tornado web server

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 100.0%