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!

Restler provides flexible and configurable JSON and XML object serialization for the web

Project Description

Restler is an object Serialization library for the web. It supports translating objects to JSON or XML. Currently, it is targeted at Google App Engine with python 2.7.


Install Restler from PyPi using easy_install or pip; or download the package and run:

python install

(Running requires setuptools.)

For use on Google App Engine, you will need to install the code in the restler directory somewhere in your path.

Running Tests

To run restler’s tests:

pip install -r requirements.txt -t lib
python -m unittest discover

Running tests requires python 2.7 the Google App Engine SDK or Google Cloud SDK


A db.Model or ndb.Model instance can be serialized with the default settings using to_json or to_xml.

>>> jean = Person(first_name="Jeanne", last_name="d'Arc", ssn="N/A")
>>> to_json(jean)
'{"first_name": "Jeanne", "last_name": "d\'Arc", "ssn": "N/A"}'

To include only certain fields, use a ModelStrategy. When using a ModelStrategy, you will need to use a restler model decorator.

>>> @ae_db_serializer
>>> class User(db.Model)
>>>    ...

Now setup the ModelStrategy

>>> person_strategy = ModelStrategy(Person).include("first_name", "last_name")
>>> to_json(jean, person_strategy)
'{"first_name": "Jeanne", "last_name": "d'Arc"}'

Or, to exclude specified fields:

>>> person_strategy = ModelStrategy(Person, include_all_fields=True).exclude("ssn")
>>> to_json(jean, person_strategy)
'{"first_name": "Jeanne", "last_name": "d'Arc"}'

For more details on customizing serialization, see the documentation.

Release History

This version
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
(30.9 kB) Copy SHA256 Hash SHA256
Egg 2.7 Apr 28, 2016
(13.7 kB) Copy SHA256 Hash SHA256
Source None Apr 28, 2016

Supported By

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 Google Google Cloud Servers