Metadata-Version: 2.4
Name: warpsock
Version: 4.2.7
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Operating System :: MacOS
Classifier: Operating System :: POSIX :: Linux
Classifier: Programming Language :: Python :: 3
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 :: Rust
Classifier: Topic :: Internet :: WWW/HTTP
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Dist: pytest ; extra == 'dev'
Requires-Dist: pytest-asyncio ; extra == 'dev'
Requires-Dist: maturin ; extra == 'dev'
Provides-Extra: dev
Summary: Python bindings for Warpsock, a Chrome-accurate HTTP client with TLS, HTTP/1.1, HTTP/2, HTTP/3, and WebSocket fingerprinting. Improved TTFT and TPS for LLMs.
Keywords: http,http2,http3,tls,fingerprint,chrome,browser,impersonate,websocket,client,async,scraping,llm,streaming,sse,ttfb
License-Expression: MIT
Requires-Python: >=3.10
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
Project-URL: Changelog, https://github.com/jaredboynton/warpsock/releases
Project-URL: Documentation, https://github.com/jaredboynton/warpsock#readme
Project-URL: Homepage, https://github.com/jaredboynton/warpsock
Project-URL: Issues, https://github.com/jaredboynton/warpsock/issues
Project-URL: Repository, https://github.com/jaredboynton/warpsock

# Warpsock

Python bindings for the Warpsock HTTP client with TLS, HTTP/2, HTTP/3, RFC 6455 WebSocket, and RFC 8441 Extended CONNECT support.

Supported Chrome fingerprints are `warpsock.FingerprintProfile.Chrome142` through `warpsock.FingerprintProfile.Chrome148`. Supported Firefox fingerprints are `warpsock.FingerprintProfile.Firefox133` through `warpsock.FingerprintProfile.Firefox151`, plus ESR branches `FirefoxEsr115`, `FirefoxEsr128`, and `FirefoxEsr140`; examples use `Chrome148`, the latest implemented Chrome profile.

## Installation

```bash
pip install warpsock
```

## HTTP

Synchronous HTTP:

```python
import warpsock

builder = warpsock.SyncClient.builder()
builder.fingerprint(warpsock.FingerprintProfile.Chrome148)
client = builder.build()

response = client.get("https://example.com/").send()
print(response.status)
print(response.text())
```

Async HTTP:

```python
import warpsock

builder = warpsock.AsyncClient.builder()
builder.fingerprint(warpsock.FingerprintProfile.Chrome148)
client = builder.build()

response = await client.get("https://example.com/").send()
print(response.status)
print(response.text())
```

## RFC 6455 WebSockets

```python
import warpsock

builder = warpsock.Client.builder()
builder.cookie_store(True)
client = builder.build()

ws_builder = client.websocket("wss://example.com/socket")
ws_builder.subprotocol("chat.v1")
ws = await ws_builder.connect()

await ws.send_text("hello")
message = await ws.next()
await ws.close(warpsock.CloseFrame(warpsock.CLOSE_NORMAL, "done"))
```

## RFC 8441 HTTP/2 Tunnels

```python
import warpsock

builder = warpsock.Client.builder()
builder.http2_prior_knowledge(True)
client = builder.build()

tunnel = await client.websocket_h2("https://example.com/h2-tunnel").connect()
await tunnel.send_bytes(b"raw bytes", end_stream=False)
data = await tunnel.recv_bytes()
await tunnel.close_send()
```

RFC 6455 framed WebSockets and RFC 8441 raw HTTP/2 tunnels are separate APIs by design.

## License

MIT

