API Reference

Python API

nhttp3.serve(app, **kwargs)

Serve an ASGI application over HTTP/3.

nhttp3.serve(app, host="0.0.0.0", port=4433, certfile="cert.pem", keyfile="key.pem")

nhttp3.Config

PropertyTypeDefaultDescription
max_idle_timeoutfloat30.0Seconds before idle connection closes
initial_max_dataint10MConnection-level flow control window
initial_max_stream_data_bidi_localint1MPer-stream flow control (local bidi)
initial_max_streams_bidiint100Max concurrent bidirectional streams
initial_max_streams_uniint100Max concurrent unidirectional streams
enable_0rttboolFalseEnable 0-RTT early data

nhttp3.Endpoint

ep = await nhttp3.Endpoint.bind(host, port, config)
conn = await ep.accept()      # server
conn = await ep.connect(h, p) # client

nhttp3.Connection

send, recv = await conn.open_bidi_stream()
send = await conn.open_uni_stream()
conn.close(error_code=0)

nhttp3.SendStream / RecvStream

n = await send.write(data)
await send.finish()
data = await recv.read(max_bytes=65536)

Node.js / WASM API

nhttp3.version()                         // "0.1.0"
nhttp3.encode_headers(pairs)              // Uint8Array (QPACK)
nhttp3.decode_headers(block)              // Array<[string,string]>
nhttp3.encode_data_frame(data)            // Uint8Array
nhttp3.encode_headers_frame(qpackBlock)  // Uint8Array
nhttp3.encode_settings_frame()            // Uint8Array

Rust API

See docs.rs/nhttp3 for full Rust API documentation (generated from source).