2.8 KiB

Web Services Made Easy


Web Services Made Easy (WSME) simplifies the writing of REST web services by providing simple yet powerful typing, removing the need to directly manipulate the request and the response objects.

WSME can work standalone or on top of your favorite Python web (micro)framework, so you can use both your preferred way of routing your REST requests and most of the features of WSME that rely on the typing system like:

  • Alternate protocols, including those supporting batch-calls
  • Easy documentation through a Sphinx extension

WSME is originally a rewrite of TGWebServices with a focus on extensibility, framework-independence and better type handling.

How Easy?

Here is a standalone WSGI example:

from wsme import WSRoot, expose

class MyService(WSRoot):
    @expose(unicode, unicode)  # First parameter is the return type,
                               # then the function argument types
    def hello(self, who=u'World'):
        return u"Hello {0} !".format(who)

ws = MyService(protocols=['restjson', 'restxml'])
application = ws.wsgiapp()

With this published at the /ws path of your application, you can access your hello function in various protocols:

URL Returns
http://<server>/ws/hello.json?who=you "Hello you !"
http://<server>/ws/hello.xml <result>Hello World !</result>

Main features

  • Very simple API.
  • Supports user-defined simple and complex types.
  • Multi-protocol : REST+JSON, REST+XML and more possible.
  • Extensible : easy to add more protocols or more base types.
  • Framework independence : adapters are provided to easily integrate your API in any web framework, for example an WSGI container, Pecan, Flask, ...
  • Very few runtime dependencies: webob, simplegeneric.
  • Integration in Sphinx for making clean documentation with wsmeext.sphinxext.


pip install WSME


Getting Help