Skip to main content

🧅 hypertor

Tor for Python. Make HTTP requests over the Tor network, and host onion services.

No Tor daemon required — hypertor speaks the Tor protocol itself, through arti, the Tor Project's Rust implementation.

pip install hypertor
import hypertor

with hypertor.Client() as client:
    response = client.get("https://check.torproject.org/api/ip")
    print(response.json())

Requests

client = hypertor.Client(
    timeout=60.0,                     # seconds, covers the whole request
    isolation="per_host",             # "none" | "per_host" | "per_request"
    max_response_size=16 * 1024**2,   # applies to the decoded body
    verify=True,
)

client.get(url, params={"q": "rust"}, headers={"X-Custom": "value"})
client.post(url, json={"name": "Alice"})
client.post(url, data={"field": "value"})       # form-urlencoded
client.request("PROPFIND", url)

response.status_code, response.ok, response.text, response.content
response.json()
response.raise_for_status()

Constructing a Client bootstraps Tor, which takes tens of seconds on a cold cache. Create one and reuse it. Every network call releases the GIL, so a slow request never freezes the rest of your program.

AsyncClient exposes exactly the same methods, awaitable:

async with hypertor.AsyncClient() as client:
    responses = await asyncio.gather(
        client.get("http://a.onion/"),
        client.get("http://b.onion/"),
    )

Circuit isolation

Two requests sharing a Tor circuit leave the network from the same exit relay at the same moment, and are linkable by anyone watching it. Isolation decides which of your activities may be linked.

alice = hypertor.IsolationToken()
bob = hypertor.IsolationToken()

client.get("http://forum.onion/inbox", isolation=alice)
client.get("http://forum.onion/profile", isolation=alice)   # same circuit
client.get("http://shop.onion/cart", isolation=bob)         # never the same circuit

Hosting an onion service

app = hypertor.OnionApp("my-service", state_dir="./onion-state")

@app.get("/")
def home(request):
    return "<h1>hello from .onion</h1>"

@app.get("/users/{user_id}")
def get_user(request):
    user = lookup(request.params["user_id"])
    if user is None:
        return {"error": "no such user"}, 404          # Flask-style (body, status)
    return user, 200, {"cache-control": "no-store"}

app.run()   # prints the .onion address, then serves until Ctrl-C

The nickname is the identity: the .onion address is derived from a key filed under it, so relaunching with the same nickname republishes the same address.

Errors

except hypertor.TimeoutError: ...
except hypertor.ConnectionError: ...      # bootstrap or connect failure
except hypertor.TlsError: ...
except hypertor.StatusError: ...          # non-2xx from raise_for_status
except hypertor.HypertorError: ...        # catches all of the above

Hostnames are scrubbed from error messages, because error messages end up in logs.

Type hints

The package ships py.typed and complete stubs, so mypy and pyright check your usage.

Documentation

Full docs: https://hupe1980.github.io/hypertor/docs/python/

The Rust library lives at crates.io/crates/hypertor and carries no Python dependency; these bindings are built from bindings/python in the repository.

A word of caution

hypertor is not an anonymity system in its own right, and no library can be. Tor protects the network path; it cannot protect you from an application that logs in with your real identity, from timing patterns in your own traffic, or from a compromised machine. Read the Tor Project's guidance before relying on this for anything that matters. Not affiliated with, endorsed by, or sponsored by the Tor Project.

License

MIT.

Metadata

Release files for hypertor 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for hypertor 0.3.0
File Size Uploaded
hypertor-0.3.0.tar.gz 286.5 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for hypertor 0.3.0
File
hypertor-0.3.0-cp310-abi3-win_amd64.whl CPython 3.10 abi3 Windows x86-64 Details
hypertor-0.3.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.10 abi3 Linux glibc 2.17+ x86-64 Details
hypertor-0.3.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl CPython 3.10 abi3 Linux glibc 2.17+ ARM64 Details
hypertor-0.3.0-cp310-abi3-macosx_11_0_arm64.whl CPython 3.10 abi3 macOS 11.0+ ARM64 Details
hypertor-0.3.0-cp310-abi3-macosx_10_12_x86_64.whl CPython 3.10 abi3 macOS 10.12+ x86-64 Details

Total release size: 49.4 MB

Release files / hypertor-0.3.0.tar.gz

Download URL hypertor-0.3.0.tar.gz
Size 286.5 kB
Tags Source
SHA-256 checksum
How to use checksums
89ddb02cdc884b3dd7ae927e319328a72133beea3b11c36f7a376f692880d7e7
BLAKE2b-256 checksum
How to use checksums
909d79e5799a585a578fdd6636e5edc35f9f96a58beab810acebf47e51ebbbc8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 15, 2026.

Transparency log

Release files / hypertor-0.3.0-cp310-abi3-win_amd64.whl

Download URL hypertor-0.3.0-cp310-abi3-win_amd64.whl
Size 10.1 MB
Tags CPython 3.10 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
261cf397d3a353bbff6788b7f1c86ba32e85bf669d98736b01d7189092ed108c
BLAKE2b-256 checksum
How to use checksums
db8ba456abdda260cce6b975b6c91b08034789eec119362a6e6b8f7a628d8470
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 15, 2026.

Transparency log

Release files / hypertor-0.3.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL hypertor-0.3.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 10.0 MB
Tags CPython 3.10 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
c8bff54d5d8587faa6d56f69a8614e26516d07fa68c0e4733c8fc8f579d91da6
BLAKE2b-256 checksum
How to use checksums
e3b74d697cd1c475bf364a226d9c343f01bdfcdc6bdfdaeeceb337be52c66faf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 15, 2026.

Transparency log

Release files / hypertor-0.3.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Download URL hypertor-0.3.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 9.7 MB
Tags CPython 3.10 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
e7f5e09d767767d9228262dd25c4793b6c1d68066b2c9f2788940547a5a3ac3a
BLAKE2b-256 checksum
How to use checksums
a9438669d3b17d15334718a6eb34ae378d53fa523fb1b88ec3730f784d7f6f46
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 15, 2026.

Transparency log

Release files / hypertor-0.3.0-cp310-abi3-macosx_11_0_arm64.whl

Download URL hypertor-0.3.0-cp310-abi3-macosx_11_0_arm64.whl
Size 9.5 MB
Tags CPython 3.10 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
635d950c9da02c7f0d86a3d2e9ae90491b6dc5d1b53c0df0b3aa6d0e0a725c93
BLAKE2b-256 checksum
How to use checksums
5f0893b19725c4b960fa74a1bc69bcf891399839ce236ec24b1c1ac8d946ee61
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 15, 2026.

Transparency log

Release files / hypertor-0.3.0-cp310-abi3-macosx_10_12_x86_64.whl

Download URL hypertor-0.3.0-cp310-abi3-macosx_10_12_x86_64.whl
Size 9.8 MB
Tags CPython 3.10 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
f5c785ff45a67787f3e7f090039be89926bb653d280bb87e842fd3d3010705bf
BLAKE2b-256 checksum
How to use checksums
7bb829fb61ef85a568136bcf2d352dfa3aa11b28987217e43b204bca8baacde6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 15, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.3.0 This release

6 release files

0.2.2

5 release files

0.2.1

5 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page