Skip to main content

requests-wasi-http

A requests transport adapter for WASI HTTP (wasi:http@0.2), so requests works inside WebAssembly components built with componentize-py.

import requests
import wit_world  # the componentize-py bindings for your WIT world
from wasi_http_adapter import WasiHttpAdapter

session = requests.Session()
adapter = WasiHttpAdapter(wit_world)  # or WasiHttpAdapter("wit_world")
session.mount("https://", adapter)
session.mount("http://", adapter)

response = session.get("https://postman-echo.com/get", timeout=5)
print(response.status_code, response.json())

Or use the convenience factory: session = wasi_http_adapter.wasi_session(wit_world).

The adapter never guesses where the bindings live: pass the componentize-py bindings package for your WIT world (a world that imports wasi:http/outgoing-handler) explicitly, either as the imported package object or as its name.

Cookies, redirects, timeouts, and streaming downloads (stream=True) work through a regular Session. TLS verification, client certificates, and proxies are owned by the WASI host and therefore ignored; Accept-Encoding is forced to identity since there is no transparent decompression.

Development

uv run pytest          # tests
uv run ruff format .   # format
uv run ruff check .    # lint
uv run ty check        # types

Release files for requests-wasi-http 0.1.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 requests-wasi-http 0.1.0
File Size Uploaded
requests_wasi_http-0.1.0.tar.gz 28.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for requests-wasi-http 0.1.0
File Interpreter ABI Platform
requests_wasi_http-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 36.5 kB

Release files / requests_wasi_http-0.1.0.tar.gz

Download URL requests_wasi_http-0.1.0.tar.gz
Size 28.0 kB
Tags Source
SHA-256 checksum
How to use checksums
52f94b9231d40eefcd8c26266a22e771c20d340608d7578d12e400b97161e79a
BLAKE2b-256 checksum
How to use checksums
1d157493616ff1d2ce5f5cf407b7e956ba8eb015050b791990dd7c4d20c57d5f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.11 {"installer":{"name":"uv","version":"0.12.11","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":true}

Release files / requests_wasi_http-0.1.0-py3-none-any.whl

Download URL requests_wasi_http-0.1.0-py3-none-any.whl
Size 8.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b007b83d52f60a4edf7aaa3d49cf7558b2d0dd403b516c2a4e7cc6b360a76154
BLAKE2b-256 checksum
How to use checksums
0eeed54a5adc0047e3fa52a51dcc5a11396d69e703125b3f63ef0e70b9226fe5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.11 {"installer":{"name":"uv","version":"0.12.11","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":true}

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 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