skip to navigation
skip to content

clients 0.4

HTTP for lazy, impatient, hubristic humans.

Package Documentation

Clients provide requests wrappers which encourage best practices, particularly always using Sessions to connect to the same host or api endpoint.


Typical requests usage is redundant and inefficient, by not taking advantage of connection pooling.

r = requests.get('', headers={'authorization': token})
r = requests.get('', headers={'authorization': token})

Using sessions is the better approach, but more verbose and in practice requires manual url joining.

s = requests.Session()
s.headers['authorization'] = token
r = s.get('')
r = s.get('')

Clients make using sessions easier, with implicit url joining.

client = clients.Client('', headers={'authorization': token})
r = client.get('user')
r = client.get('user/repos')

Resources extend Clients to implicitly handle response content, with proper checking of status_code and content-type.

resource = clients.Resource('', headers={'authorization': token})
for repo in resource.get('user/repos'):

Being session based, Clients also work seamlessly with other requests adapters, such as CacheControl.

Asynchronous Clients are also provided, using aiohttp instead of requests.

See documentation for more examples.


$ pip install clients


  • Python 2.7, 3.4+
  • requests 2.4.2+
  • aiohttp (optional)


100% branch coverage.

$ pytest [--cov]



  • Asynchronous clients and resources


  • singleton decorator


  • Resource attribute upcasts back to a client
  • iter and download implement GET requests with streamed content
  • create implements POST request and returns Location header
  • update implements PATCH request with json params
  • __call__ implements GET request with params
File Type Py Version Uploaded on Size
clients-0.4-py2.py3-none-any.whl (md5) Python Wheel py2.py3 2017-06-11 7KB
clients-0.4.tar.gz (md5) Source 2017-06-11 14KB