httpx-socks
The httpx-socks package provides proxy transports for httpx client.
SOCKS4(a), SOCKS5(h), HTTP CONNECT proxy supported.
It uses python-socks for core proxy functionality.
Requirements
- Python >= 3.8
- httpx>=0.28.0,<0.29.0
- python-socks>=2.4.3,<3.0.0
- trio>=0.24 (optional)
- anyio>=3.3.4,<5.0.0 (optional)
Installation
only sync proxy support:
pip install httpx-socks
to include optional asyncio support (it requires async-timeout):
pip install httpx-socks[asyncio]
to include optional trio support:
pip install httpx-socks[trio]
Usage
sync transport
import httpx
from httpx_socks import SyncProxyTransport
def fetch(url):
transport = SyncProxyTransport.from_url('socks5://user:password@127.0.0.1:1080')
with httpx.Client(transport=transport) as client:
res = client.get(url)
return res.text
async transport (asyncio, trio)
import httpx
from httpx_socks import AsyncProxyTransport
async def fetch(url):
transport = AsyncProxyTransport.from_url('socks5://user:password@127.0.0.1:1080')
async with httpx.AsyncClient(transport=transport) as client:
res = await client.get(url)
return res.text
secure proxy connections (aka "HTTPS proxies", experimental feature, both sync and async support)
import ssl
import httpx
from httpx_socks import AsyncProxyTransport
async def fetch(url):
proxy_ssl = ssl.SSLContext(ssl.PROTOCOL_TLS)
proxy_ssl.verify_mode = ssl.CERT_REQUIRED
proxy_ssl.load_verify_locations(...)
transport = AsyncProxyTransport.from_url('http://user:password@127.0.0.1:8080', proxy_ssl=proxy_ssl)
async with httpx.AsyncClient(transport=transport) as client:
res = await client.get(url)
return res.text
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
httpx_socks-0.13.0.tar.gz
(120.9 kB
view details)
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 httpx_socks-0.13.0.tar.gz.
File metadata
- Download URL: httpx_socks-0.13.0.tar.gz
- Upload date:
- Size: 120.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
uv/0.12.1 {"installer":{"name":"uv","version":"0.12.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
de4fd454dc95612e484e61f68229c1c0366a54b1a4ba6474cdfae8cb64820831
|
|
| MD5 |
02ced5a07ae3ef5cd4acf85eb324cfb6
|
|
| BLAKE2b-256 |
e01f93ec5f88543f9b2466c8940603bd0cb7472d8d7ceab7332e527fed8a5504
|
File details
Details for the file httpx_socks-0.13.0-py3-none-any.whl.
File metadata
- Download URL: httpx_socks-0.13.0-py3-none-any.whl
- Upload date:
- Size: 13.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
uv/0.12.1 {"installer":{"name":"uv","version":"0.12.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7419783d922e8172dd7742093d6cc32f9796025d9b3dec062696215f726d3124
|
|
| MD5 |
60301487b15f49b447057fce2172cbac
|
|
| BLAKE2b-256 |
a7b32c2d7d6845f7519cfd8e2d9ee578bc0a92f97d1f087c5ed271884d165d7e
|