Skip to main content

HTTP for humanitarians.

Project description

image image image image image image image image image

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

httpx is on track to reach 1.0 status before requests3 is available, and natively supports a base URL on its client. The next version of clients is planned to use only httpx.


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.

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

Resources also implement syntactic support for methods such as getattr and call, providing most of the benefits of custom clients as is.

for repo in github.user.repos(visibility='public'):

Asynchronous variants of all client types are provided, using httpx instead of requests. Additional clients for RPC, GraphQL, and proxies also provided.


% pip install clients


  • requests >=2.23
  • httpx >=0.15


100% branch coverage.

% pytest [--cov]



  • httpx >=0.15 required
  • requests deprecated


  • Python 3 required
  • httpx >=0.11 required


  • Async switched to httpx


  • Allow missing content-type
  • Oauth access tokens supported in authorization header


  • AsyncClient default params
  • Remote and AsyncRemote procedure calls
  • Graph and AsyncGraph execute GraphQL queries
  • Proxy and AsyncProxy clients


  • 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

Project details

Download files

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

Source Distribution

clients-1.3.tar.gz (12.2 kB view hashes)

Uploaded source

Built Distribution

clients-1.3-py3-none-any.whl (9.3 kB view hashes)

Uploaded py3

Supported by

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