https://github.com/vspaz/pyclient
configurable HTTP python client that supports retries, timeouts, tls, basic auth, logging etc.
https://github.com/vspaz/pyclient
basic-authentication http http-client logging python3 requests retries timeouts tls tls-certificate
Last synced: 8 months ago
JSON representation
configurable HTTP python client that supports retries, timeouts, tls, basic auth, logging etc.
- Host: GitHub
- URL: https://github.com/vspaz/pyclient
- Owner: vspaz
- License: mit
- Created: 2021-09-30T19:41:44.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2025-01-17T22:23:43.000Z (9 months ago)
- Last Synced: 2025-01-17T23:25:51.898Z (9 months ago)
- Topics: basic-authentication, http, http-client, logging, python3, requests, retries, timeouts, tls, tls-certificate
- Language: Python
- Homepage:
- Size: 50.8 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# pyclient
configurable HTTP python client that supports
- tls,
- basic auth,
- retries on specific errors,
- timeouts,
- logging
- uses ultra-fast 'ujson' library for serialization'
- etc.### Install pyclient
```shell
git clone clone git@github.com:vspaz/pyclient.git
cd pyclientpip3 install .
````### Run tests
```shell
pip3 install -r requirements/dev.txt
make test
```### Use
```python
from pyclient.http import PyClientif __name__ == '__main__':
http_client = PyClient.get_http_client(host='https://httpbin.org')
http_client.set_retries(count=3, backoff=1.5, on_errors=[500, 502, 504, 429])
http_client.set_timeouts(connect=5, read=5)
http_client.set_user_agent(ua='myClient')
http_client.set_basic_auth(user='user', password='password')
# http_client.set_tls(
# client_key_path='path/to/key',
# client_certificate_path='path/to/client/certificate',
# ca_path='path/to/ca',
# )
print(http_client.do_get(path='/get').json())# or simply
http_client = PyClient.get_http_client()
print(http_client.do_get(path='https://httpbin.org/get').json())
```