Secure by default
Verified TLS and five-second phase timeouts. Redirects are a deliberate choice.
A native synchronous HTTP client. From a simple GET to persistent sessions and streaming responses — with an API that stays out of your way.
HTTP/1.1 · Verified HTTPS · Native JSON
import req
def main() raises:
var response = req.get("https://example.com")
response.raise_for_status()
print(response.status_code)
print(response.text())
import req
def main() raises:
var owner = req.Client(base_url="https://example.com/")
with owner.context() as client:
var response = client.get("/")
response.raise_for_status()
print(response.text())
import req
def main() raises:
with req.stream("GET", "https://example.com") as body:
body.raise_for_status()
while True:
var chunk = body.read_chunk(65536)
if not chunk:
break
print(len(chunk.value()))
A small, explicit API for the work between your application and the network.
Verified TLS and five-second phase timeouts. Redirects are a deliberate choice.
Reuse connections and keep headers, authentication, and scoped cookies in one client.
Send JSON, forms, or bytes. Read responses as text, structured JSON, or raw content.
Read chunks as they arrive, with incremental gzip and deflate decoding.
Build from source, then follow the guide to link the native transport and run a Mojo program.
Read the installation guidegit clone https://github.com/mojoto/req.mojo.git
cd req.mojo
pixi install
make build