{"id":16802924,"url":"https://github.com/coady/clients","last_synced_at":"2025-06-13T02:33:02.333Z","repository":{"id":7004680,"uuid":"53901790","full_name":"coady/clients","owner":"coady","description":"High-level HTTP clients for Python.","archived":false,"fork":false,"pushed_at":"2025-01-23T02:45:09.000Z","size":766,"stargazers_count":16,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-05-03T20:36:49.751Z","etag":null,"topics":["asyncio","httpx","requests","sessions"],"latest_commit_sha":null,"homepage":"https://coady.github.io/clients","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/coady.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-03-15T00:24:19.000Z","updated_at":"2025-04-09T10:10:57.000Z","dependencies_parsed_at":"2023-12-03T12:44:05.546Z","dependency_job_id":"e13935dd-5012-495a-a4ba-1c7bab5d1897","html_url":"https://github.com/coady/clients","commit_stats":{"total_commits":114,"total_committers":2,"mean_commits":57.0,"dds":0.07017543859649122,"last_synced_commit":"5d4fdcdd6653426cdeebf7d3073e9082bfc96785"},"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coady%2Fclients","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coady%2Fclients/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coady%2Fclients/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coady%2Fclients/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/coady","download_url":"https://codeload.github.com/coady/clients/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coady%2Fclients/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":258287713,"owners_count":22677936,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["asyncio","httpx","requests","sessions"],"created_at":"2024-10-13T09:41:04.850Z","updated_at":"2025-06-13T02:33:02.280Z","avatar_url":"https://github.com/coady.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![image](https://img.shields.io/pypi/v/clients.svg)](https://pypi.org/project/clients/)\n![image](https://img.shields.io/pypi/pyversions/clients.svg)\n[![image](https://pepy.tech/badge/clients)](https://pepy.tech/project/clients)\n![image](https://img.shields.io/pypi/status/clients.svg)\n[![build](https://github.com/coady/clients/actions/workflows/build.yml/badge.svg)](https://github.com/coady/clients/actions/workflows/build.yml)\n[![image](https://codecov.io/gh/coady/clients/branch/main/graph/badge.svg)](https://codecov.io/gh/coady/clients/)\n[![CodeQL](https://github.com/coady/clients/actions/workflows/github-code-scanning/codeql/badge.svg)](https://github.com/coady/clients/actions/workflows/github-code-scanning/codeql)\n[![image](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)\n[![image](https://mypy-lang.org/static/mypy_badge.svg)](https://mypy-lang.org/)\n\nClients originally provided [requests](https://python-requests.org) wrappers to encourage best practices, particularly always using Sessions to connect to the same host or api endpoint. The primary goals were:\n* provide a `Client` object with a convenient constructor\n* support a base url so that requests can provide a relative path\n* provide the same interface for asyncio\n\nSince then [httpx](https://www.encode.io/httpx) has emerged as the successor to `requests`, and supports the above features natively. So `clients.Client` can be replaced with `httpx.Client` for most use cases. The project will continue to be maintained for additional features, such as the `Resource` object.\n\n## Usage\nTypical `requests` usage is redundant and inefficient, by not taking advantage of connection pooling.\n\n```python\nr = requests.get('https://api.github.com/user', headers={'authorization': token})\nr = requests.get('https://api.github.com/user/repos', headers={'authorization': token})\n```\n\nUsing sessions is the better approach, but more verbose and in practice requires manual url joining.\n\n```python\ns = requests.Session()\ns.headers['authorization'] = token\nr = s.get('https://api.github.com/user')\nr = s.get('https://api.github.com/user/repos')\n```\n\n### Client\nClients make using sessions easier, with implicit url joining.\n\n```python\nclient = clients.Client('https://api.github.com/', headers={'authorization': token})\nr = client.get('user')\nr = client.get('user/repos')\n```\n\n### Resource\nResources extend Clients to implicitly handle response content, with proper checking of status_code and content-type.\n\n```python\ngithub = clients.Resource('https://api.github.com/', headers={'authorization': token})\nfor repo in github.get('user/repos', params={'visibility': 'public'}):\n    ...\n```\n\nResources also implement syntactic support for methods such as __getattr__ and __call__, providing most of the benefits of custom clients as is.\n\n```python\nfor repo in github.user.repos(visibility='public'):\n    ...\n```\n\nAsynchronous variants of all client types are provided, e.g., `AsyncClient`. Additional clients for [RPC](https://en.wikipedia.org/wiki/Remote_procedure_call), [GraphQL](https://graphql.org), and proxies also provided.\n\n## Installation\n```console\n% pip install clients\n```\n\n## Dependencies\n* httpx\n\n## Tests\n100% branch coverage.\n```console\n% pytest [--cov]\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcoady%2Fclients","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcoady%2Fclients","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcoady%2Fclients/lists"}