Skip to main content

REST client

Project description

A REST client - inspired by restmod for javascript.

Test status

Codeship Status for garymonson/peace

Quick start for contributing

virtualenv -p `which python3` virtualenv
source virtualenv/bin/activate
pip install -r requirements.txt
pip install -r dev_requirements.txt


from peace import PeaceMaker

def set_authorization_header(request):
    request.headers['Authorization'] = authorization_value
    return request

maker = PeaceMaker('')
Employee = maker.make(
    has: {
        'user': maker.make('Company'),
    intercept: set_authorization_header,

employees ='Smith')
bob = Employee.get('100')
bob.last_name = 'Smith-Jones'
company =
print( # prints name

Peace requires the REST API to conform to a particular structure. A JSON response should look something like this:

  "data": {
    "id": 100,
    "first_name": "Bob",
    "last_name": "Smith",
  "links": {
    "self": {"href": "/employees/100"},
    "company": {
      "href": "/companies/5",
      "data": {
        "name": "Big Corp",

Links can be followed (e.g. Initially, the data returned in the original request will be immediately available, but if you try to access other fields that a direct load is required to make available, (i.e. were not in the original response), then a load of the linked object will be done first (e.g. GET /companies/5).

Project details

Download files

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

Files for peace, version 0.0.8
Filename, size File type Python version Upload date Hashes
Filename, size peace-0.0.8.tar.gz (7.0 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page