---
title: "HTTPX"
description: "Learn about the HTTPX integration and how it adds support for the HTTPX HTTP client."
url: https://docs.sentry.io/platforms/python/integrations/httpx/
---

# HTTPX | Sentry for Python

The [HTTPX](https://www.python-httpx.org/) integration instruments outgoing HTTP requests using either the sync or the async HTTPX clients.

Use this integration to create spans for outgoing requests and ensure traces are properly propagated to downstream services.

## [Install](https://docs.sentry.io/platforms/python/integrations/httpx.md#install)

Install `sentry-sdk` from PyPI:

```bash
pip install sentry-sdk
```

## [Configure](https://docs.sentry.io/platforms/python/integrations/httpx.md#configure)

The HTTPX integration is enabled automatically if you have the `httpx` package installed.

Error Monitoring\[ ]Tracing\[ ]Profiling\[ ]Logs

```python
import sentry_sdk

sentry_sdk.init(
    dsn="___PUBLIC_DSN___",
    # Add data like request headers and IP for users, if applicable;
    # see https://docs.sentry.io/platforms/python/data-management/data-collected/ for more info
    send_default_pii=True,
    # ___PRODUCT_OPTION_START___ performance
    # Set traces_sample_rate to 1.0 to capture 100%
    # of transactions for tracing.
    traces_sample_rate=1.0,
    # ___PRODUCT_OPTION_END___ performance
    # ___PRODUCT_OPTION_START___ profiling
    # To collect profiles for all profile sessions,
    # set `profile_session_sample_rate` to 1.0.
    profile_session_sample_rate=1.0,
    # Profiles will be automatically collected while
    # there is an active span.
    profile_lifecycle="trace",
    # ___PRODUCT_OPTION_END___ profiling
    # ___PRODUCT_OPTION_START___ logs

    # Enable logs to be sent to Sentry
    enable_logs=True,
    # ___PRODUCT_OPTION_END___ logs
)
```

## [Verify](https://docs.sentry.io/platforms/python/integrations/httpx.md#verify)

```python
import httpx

def main():
    sentry_init(...)  # same as above
    with sentry_sdk.start_transaction(name="testing_sentry"):
        r1 = httpx.get("https://sentry.io/")
        r2 = httpx.post("http://httpbin.org/post")

main()
```

This will create a transaction called `testing_sentry` in the Performance section of [sentry.io](https://sentry.io), and create spans for the outgoing HTTP requests.

It takes a couple of moments for the data to appear in [sentry.io](https://sentry.io).

## [Supported Versions](https://docs.sentry.io/platforms/python/integrations/httpx.md#supported-versions)

* HTTPX: 0.16+
* Python: 3.6+
