Metadata-Version: 2.4
Name: bazooka
Version: 1.3.3
Summary: Reliable HTTP client
Author: InfraGuys
License: Apache-2.0
Project-URL: homepage, https://github.com/infraguys/bazooka/
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Operating System :: POSIX :: Linux
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: requests<3.0.0,>=2.32.4
Requires-Dist: yretry<2.0.0,>=1.0.1
Provides-Extra: dev
Requires-Dist: tox>=4.0.0; extra == "dev"
Requires-Dist: tox-uv; extra == "dev"
Requires-Dist: pytest>=7.0.0; extra == "dev"
Provides-Extra: test
Requires-Dist: coverage>=4.0; extra == "test"
Requires-Dist: mock<4.0.0,>=3.0.5; extra == "test"
Requires-Dist: pytest<9.0.0,>=8.0.0; extra == "test"
Requires-Dist: pytest-timer<2.0.0,>=1.0.0; extra == "test"
Provides-Extra: mypy
Requires-Dist: mypy; extra == "mypy"
Provides-Extra: ruff
Requires-Dist: ruff; extra == "ruff"
Provides-Extra: shellcheck
Requires-Dist: shellcheck-py; extra == "shellcheck"
Dynamic: license-file

Bazooka - reliable HTTP client
==============================

![tests workflow](https://github.com/infraguys/bazooka/actions/workflows/tests.yaml/badge.svg)

Overview
--------

Bazooka is a reliable and efficient HTTP client for Python that provides
features such as retries out of the box, full compatibility with the
`requests` library, and customizable logging options.

Key Features
------------

*   **retries**: Bazooka includes built-in retry logic to handle temporary network failures or 5XX server errors.
*   **full compatibility**: Bazooka is designed to work seamlessly with the `requests` library, allowing for easy integration into existing projects.
*   **explicit automatic error handling**: by default client raises exception if status code isn't 2xx.
*   **curl-like customizable Logging**: Bazooka offers flexible logging options, including duration logging and sensitive logging support.

Example Usage
-------------

### Basic Example

```python
import bazooka

client = bazooka.Client()
print(client.get('http://example.com').json())
```

### Using Correlation IDs

(Usable to match bazooka requests with your business logic logs)

```python
from bazooka import correlation

client = bazooka.Client(correlation_id='my_correlation_id')
print(client.get('http://example.com').json())
```

### Raised Exceptions on 4xx Errors

```python
import bazooka
from bazooka import exceptions

client = bazooka.Client()

try:
    response = client.get('http://example.com', timeout=10)
except exceptions.NotFoundError:
    # process 404 error
    pass
except exceptions.ConflictError:
   # process 409 error
    pass
except exceptions.BaseHTTPException as e:
   # process other HTTP errors
    if e.code in range(400, 500):
        print(f"4xx Error: {e}")
    else:
        raise
```

Getting Started
---------------

To get started with Bazooka, install it via pip:

```bash
pip install bazooka
```
