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!

A dynamic rest client

Project Description

RestDyn is a dynamic rest client built on top of the excellent restkit library.

It aims to be able to handle any uris for any apis.

How it work ?

Let’s say we want to fetch the json API of the great service Their api is served from

>>> from restdyn import Client
>>> ExampleAPI = Client('')

Now we want to get the result from

>>> results ='Timy')

That’s it ! results is a json object.

Going further

Adding arguments automatically

Sometimes some api are a bit tricky. Previously, the version of the api was part of the resource but what if we have to specify it for each request:

We can specify one or more params which will be automatically add to the query:

>>> ExampleAPI = Client('')
>>> ExampleAPI.set_persistent_params(v="1.0")

or you can pass a dict:

>>> ExampleAPI.set_persistent_params({'v':'1.0'})

Customize resources

Some apis like Twitter add .json after the resource but before the query : We can do it like this:

>>> TwitterAPI = Client('', end_resource='.json')
>>> results ='Timy')

Post process result

Sometimes you may have to clean up the result before send it back. You can do it by overloading the Client.post_process_result method.


Google’s web service won’t send an http error 400 if the request failed. Instead, it will send a custom result:

will send back:

{"responseData": null, "responseDetails": "invalid version", "responseStatus": 400}

Let’s say we want to catch the error and raise an RequestFailed exception with a custom message which is in the “responseDetails” field:

class CustomGoogleAPI(Client):
    def post_process_result(self, result):
        if result["responseStatus"] == 400:
            raise RequestFailed(result['responseDetails'])
        return result

That’s it ! Don’t forget to return the result at the end of the post_process_result method.

>>> GoogleAPI = CustomGoogleAPI('')
Traceback (most recent call last):
RequestFailed: invalid version

Adding a trailing slash

If the api you are dealing have a slash in all its urls, you can configure restdyn to add it:

>>> example_api = Client('', add_trailing_slash=True)

Release History

This version
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
(84.3 kB) Copy SHA256 Hash SHA256
Source None Sep 2, 2011

Supported By

Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Kabu Creative Kabu Creative UX & Design Google Google Cloud Servers Fastly Fastly CDN StatusPage StatusPage Statuspage DigiCert DigiCert EV Certificate