Welcome to restutils’s documentation!

Indices and tables

About

restutils is a python library provides you easy methods to work with REST APIs. Its provides client side methods to interact with your REST server

Future Enhancements

We will add libraries for creating simple REST API servers also in upcoming releases.

Install

The easiest way to install restutils is via pip:

pip install restutils

Classes

class restutils.RESTClient(base_url, content_type=”application/json”, username=None, password=None, session=None, log=sys.stderr)

provides a simple way to interact with HTTP/HTTPs RESTful resources.

get(url_path, **kwargs)

Perform an HTTP(s) GET to the resource specified in url_path. Takes an optional ref of custom request headers.

post(self, url_path, request_body=”“, **kwargs)

Perform an HTTP(s) POST to the resource specified. Takes an optional body content and reference of custom request headers.

put(self, url_path, request_body=”“, **kwargs)

Perform an HTTP(s) PUT to the resource specified. Takes an optional body content and ref of custom request headers.

delete(self, url_path, **kwargs)

Perform an HTTP(s) DELETE to the resource specified. Takes an optional ref of custom request headers.

create_session(auth_url, body=”“, status=httplib.ACCEPTED, username=None, password=None)

If your API supports session handling feature you can create a session using this method and use it in other methods

delete_session(self, auth_url, status=httplib.NO_CONTENT)

This method helps in deleting the exists session and creared by create_session method

Usage

How to use classes
>>> from restutils import RESTClient
>>> client = RESTClient()