skip to navigation
skip to content

shad 0.1.0

Generic restful api -> Python function call adaptor

Latest Version: 0.1.4


Small framework for building RESTful API wrappers.



Define your base API class

from shad import BaseAPI, APIFunction, get_bind

class MyAPI(BaseAPI):
def __init__(self, api_key, base_url=""):
self.api_key = api_key
self.base_url = base_url

def update_parameters(self, params):
params["key"] = self.api_key
return params

`base_url` is required, and used by the method `get_base_url` to build the requests url. You can override `get_base_url` if you want to include variable constants in your base url in every request.

Next define your end points

bind = get_bind(MyAPI)

class mycall(APIFunction):
path = "accounts/login/"
method = "GET"

Then a user of your wrapper can do this:

r = api.mycall(format='json')

By default, call return insteads of the Python requests libraries response objects, which you can call `.json` on to get back json if that is what you expect.


This breaks the paradigm of just calling function and getting back a workable response, I need to change this such that we return an object which is by default the data in json form (or xml form), and you can also get the reponse back too.  
File Type Py Version Uploaded on Size
shad-0.1.0.tar.gz (md5) Source 2014-03-03 3KB
  • Downloads (All Versions):
  • 2 downloads in the last day
  • 66 downloads in the last week
  • 347 downloads in the last month