Async httpx wrapper that auto-manages a local Tor process (downloads Tor on first run).
Project description
tor-http (auto-download Tor on first run)
tor-http is a privacy-oriented async wrapper around httpx that routes requests through a locally managed Tor process.
This package follows a download-on-first-run strategy (no bundled Tor binaries in the wheel/sdist):
- ✅ No Tor binary redistribution in your PyPI artifact
- ✅ Works cross-platform (Windows / Linux / macOS)
- ✅ Uses the Tor Project “Tor Expert Bundle” as the source
Notes
- This library is intended for privacy-oriented routing. It does not guarantee a new Tor exit IP per request.
- Tor can be rate-limited or blocked on some networks.
- If your environment is air-gapped or blocks downloads, set an explicit
TORHTTP_TOR_CMD(system Tor).
Install
pip install tor-http
Quick start
from tor_http import tor_http
async def main():
r = await tor_http.get("https://httpbin.org/ip")
print(r.status_code, r.text)
How Tor is obtained (Option A)
On first use, tor-http will:
- Look for an explicit Tor binary (
TORHTTP_TOR_CMDorTorHttpOptions(tor_cmd=...)) - Otherwise, check the local cache (previous download)
- Otherwise, try
torfrom your system PATH - Otherwise, download the Tor Expert Bundle from the Tor Project and cache it
The downloaded bundle is cached in your user cache directory (via platformdirs), e.g.:
- Windows:
%LOCALAPPDATA%\tor-http\tor\... - macOS:
~/Library/Caches/tor-http/tor/... - Linux:
~/.cache/tor-http/tor/...
Environment variables
TORHTTP_TOR_CMD— path to an existing Tor binary (skips download)TORHTTP_TOR_URL— override the download URL (advanced / mirrors / pinned versions)TORHTTP_TOR_SHA256— expected SHA256 for the archive atTORHTTP_TOR_URL(recommended if you override the URL)
License
This project is MIT licensed (see LICENSE).
Tor is developed and distributed by The Tor Project. This project is not affiliated with or endorsed by The Tor Project.
Permissions
This package does not require administrator or sudo privileges. Tor is downloaded (if needed) and executed entirely in user space.
Usage (module singleton)
from tor_http import tor_http
r = await tor_http.get("https://httpbin.org/get")
print(r.status_code, r.json())
Usage (class)
from tor_http import TorHttp, TorHttpOptions
client = TorHttp(TorHttpOptions(use_tor=True))
r = await client.get("http://ip-api.com/json/")
print(r.status_code)
await client.close()
Best-effort refresh
ok = await tor_http.try_refresh()
This restarts Tor+client for reliability. It does not promise a new exit IP.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file tor_http-0.0.1.tar.gz.
File metadata
- Download URL: tor_http-0.0.1.tar.gz
- Upload date:
- Size: 10.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.8.20
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c12fd943bbca298f0df77f316906d256b0efa0321882085b709c73d3c2be56e5
|
|
| MD5 |
0e5fd6fa809a5c9a9bcf898bd726041c
|
|
| BLAKE2b-256 |
10f9f718d18639a6d698b81a29c470051b1a78c1bbfedaf48c3574da6e9353cb
|
File details
Details for the file tor_http-0.0.1-py3-none-any.whl.
File metadata
- Download URL: tor_http-0.0.1-py3-none-any.whl
- Upload date:
- Size: 11.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.8.20
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
086f22f5603d0b9d6676559ee7dc67bdfde1ffa4a93912ca4f404382e47d7908
|
|
| MD5 |
d1d7ce12bebe735415a60fbbfd1a1c42
|
|
| BLAKE2b-256 |
74e9d6305164ca641b799f668d2654ec364cdb2c279e525c86a33b9a7623ebdf
|