| Platform | Architectures |
|---|---|
| macOS | arm64, x86_64 |
| Linux | x86_64, aarch64 (glibc) |
| Windows | x86_64 |
- API reference: Python API docs
- Example app: hello-iroh-ffi, a console reader for the cross-platform dot demo
- All languages: platform support matrix
Install
- Linux:
x86_64andaarch64(manylinux 2_28) - macOS:
arm64andx86_64 - Windows:
amd64
Register your event loop
Before calling any other iroh API, hand your asyncio event loop to the bindings:uniffi_set_event_loop tells them which loop to use. Without it, the bindings fall back to asyncio.get_running_loop(), which raises RuntimeError: no running event loop when called from a Rust thread. In practice this surfaces as that exact error, or as an await that never completes.
The awkward name comes from uniffi, the tool that generates the bindings, which is also why it lives under iroh.iroh_ffi rather than on the iroh module itself.
Two rules of thumb:
- Call it from inside a running coroutine, typically as the first line of the function you pass to
asyncio.run(). It cannot go at module level, becauseasyncio.get_running_loop()only works while a loop is running. - Register once per event loop. If your program creates more than one loop (repeated
asyncio.run()calls, or pytest-asyncio’s per-test loops), register each new loop before using iroh on it. In a test suite, an autouse fixture handles this:
Hello, iroh
n0 preset, advertises a single ALPN, and prints the endpoint id once binding completes.
A two-peer echo
The main.py example in the iroh-ffi repo runs a sender/receiver pair over QUIC:hello, and prints what the other peer echoes back.
Next steps
Connect two endpoints
Conceptual walkthrough of endpoints, tickets, and ALPNs. The code samples are Rust, but every API maps 1:1 to Python.
hello-iroh-ffi example app
A headless Python peer for the cross-platform dot demo. It speaks the same wire format as the Swift and Kotlin apps and prints received positions to the console.
Python API reference
Full class, method, and enum reference generated from the uniffi-rs bindings.
iroh-ffi on GitHub
Source, examples, and issue tracker for the Python (and other-language) bindings.