Metadata-Version: 2.4
Name: tusk-drift-python-sdk
Version: 0.1.8
Summary: Python SDK for Tusk Drift instrumentation and replay
Author-email: Tusk <support@usetusk.ai>
License: MIT
Project-URL: Homepage, https://usetusk.ai
Project-URL: Documentation, https://docs.usetusk.ai
Project-URL: Repository, https://github.com/Use-Tusk/drift-node-sdk
Project-URL: Issues, https://github.com/Use-Tusk/drift-node-sdk/issues
Keywords: tusk,drift,testing,instrumentation,tracing,replay
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Software Development :: Testing
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.12
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: protobuf>=6.0
Requires-Dist: PyYAML>=6.0
Requires-Dist: requests>=2.32.5
Requires-Dist: tusk-drift-schemas>=0.1.9.dev1
Requires-Dist: aiohttp>=3.9.0
Requires-Dist: aiofiles>=23.0.0
Requires-Dist: opentelemetry-api>=1.20.0
Requires-Dist: opentelemetry-sdk>=1.20.0
Requires-Dist: time-machine>=2.10.0
Provides-Extra: flask
Requires-Dist: Flask>=3.1.2; extra == "flask"
Provides-Extra: fastapi
Requires-Dist: fastapi>=0.115.6; extra == "fastapi"
Requires-Dist: uvicorn>=0.34.2; extra == "fastapi"
Requires-Dist: starlette<0.42.0; extra == "fastapi"
Provides-Extra: django
Requires-Dist: Django>=5.0; extra == "django"
Provides-Extra: dev
Requires-Dist: Flask>=3.1.2; extra == "dev"
Requires-Dist: fastapi>=0.115.6; extra == "dev"
Requires-Dist: uvicorn>=0.34.2; extra == "dev"
Requires-Dist: python-jsonpath>=0.10; extra == "dev"
Requires-Dist: ruff>=0.8.0; extra == "dev"
Requires-Dist: ty>=0.0.1a7; extra == "dev"
Requires-Dist: pytest>=8.0.0; extra == "dev"
Dynamic: license-file

<p align="center">
  <img src="https://github.com/Use-Tusk/drift-python-sdk/raw/main/images/tusk-banner.png" alt="Tusk Drift Banner">
</p>

<p align="center">
  <a href="https://pypi.org/project/tusk-drift-python-sdk/"><img src="https://img.shields.io/pypi/v/tusk-drift-python-sdk" alt="PyPI version"></a>
  <a href="https://opensource.org/licenses/Apache-2.0"><img src="https://img.shields.io/badge/License-Apache_2.0-blue.svg" alt="License: Apache 2.0"></a>
  <a href="https://github.com/Use-Tusk/drift-python-sdk/commits/main/"><img src="https://img.shields.io/github/last-commit/Use-Tusk/drift-python-sdk" alt="GitHub last commit"></a>
  <a href="https://x.com/usetusk"><img src="https://img.shields.io/twitter/url?url=https%3A%2F%2Fx.com%2Fusetusk&style=flat&logo=x&label=Tusk&color=BF40BF" alt="Tusk X account"></a>
  <a href="https://join.slack.com/t/tusk-community/shared_invite/zt-3fve1s7ie-NAAUn~UpHsf1m_2tdoGjsQ"><img src="https://img.shields.io/badge/slack-badge?style=flat&logo=slack&label=Tusk&color=BF40BF" alt="Tusk Community Slack"></a>
</p>

The Python Tusk Drift SDK enables fast and deterministic API testing by capturing and replaying API calls made to/from your service. Automatically record real-world API calls, then replay them as tests using the [Tusk CLI](https://github.com/Use-Tusk/tusk-drift-cli) to find regressions. During replay, all outbound requests are intercepted with recorded data to ensure consistent behavior without side-effects.

<div align="center">

![Demo](images/demo.gif)

<p><a href="https://github.com/Use-Tusk/drift-python-demo">Try it on a demo repo →</a></p>

</div>

## Documentation

For comprehensive guides and API reference, visit our [full documentation](https://docs.usetusk.ai/api-tests/installation#setup).

### SDK Guides

- [Initialization Guide](docs/initialization.md) - Set up the SDK in your Python application
- [Environment Variables](docs/environment-variables.md) - Environment variables reference
- [Quick Start Guide](docs/quickstart.md) - Record and replay your first trace

<div align="center">

![Tusk Drift Animated Diagram](images/tusk-drift-animated-diagram-light.gif#gh-light-mode-only)
![Tusk Drift Animated Diagram](images/tusk-drift-animated-diagram-dark.gif#gh-dark-mode-only)

</div>

## Requirements

- Python 3.12+

Tusk Drift currently supports the following packages and versions:

- **Flask**: `flask>=2.0.0`
- **FastAPI**: `fastapi>=0.68.0`
- **Django**: `django>=3.2.0`
- **Requests**: `requests` (all versions)
- **HTTPX**: `httpx` (all versions)
- **psycopg**: `psycopg>=3.0.0`, `psycopg2>=2.8.0`
- **Redis**: `redis` (all versions)

If you're using packages or versions not listed above, please create an issue with the package + version you'd like an instrumentation for.

## Installation

### Step 1: Install the CLI

First, install and configure the Tusk Drift CLI by following our [CLI installation guide](https://github.com/Use-Tusk/tusk-drift-cli?tab=readme-ov-file#install). The CLI helps set up your Tusk configuration file and replays tests.

The wizard will eventually direct you back here when it's time to set up the SDK.

### Step 2: Install the SDK

After completing the CLI wizard, install the SDK:

```bash
pip install tusk-drift-python-sdk
```

#### With Framework Support

```bash
# With Flask support
pip install tusk-drift-python-sdk[flask]

# With FastAPI support
pip install tusk-drift-python-sdk[fastapi]

# With Django support
pip install tusk-drift-python-sdk[django]
```

### Step 3: Initialize the SDK for your service

Refer to our [initialization guide](docs/initialization.md) to set up the SDK for your service.

### Step 4: Run Your First Test

Follow along our [quick start guide](docs/quickstart.md) to record and replay your first test!

## Troubleshooting

Having issues?

- Check our [initialization guide](docs/initialization.md) for common setup issues
- Create an issue or reach us at [support@usetusk.ai](mailto:support@usetusk.ai).

## Community

Join our open source community on [Slack](https://join.slack.com/t/tusk-community/shared_invite/zt-3fve1s7ie-NAAUn~UpHsf1m_2tdoGjsQ).

## Contributing

We appreciate feedback and contributions. See [CONTRIBUTING.md](/CONTRIBUTING.md).

## License

This project is licensed under the Apache License 2.0 - see the [LICENSE](LICENSE) file for details.
