HTTP-request-from-inside-WASM
HTTP-request-from-inside-WASM copied to clipboard
(Wannabe-awesome) list of methods to make outbound HTTP(S) requests from within WebAssembly in many languages
Make HTTP request from inside WebAssembly
(Wannabe-awesome) list of approaches (recipes, frameworks, http client libraries, etc) to send outbound HTTP(S) requests from inside WebAssembly.
Contents
| Language | Browsers and V8-based runtimes | Standalone / server-side / WASI runtimes |
|---|---|---|
| Ada |
AdaWebPack |
|
| AssemblyScript |
as-fetch |
wasi-experimental-http, wasi-http-ts, wasi-http |
| BASIC |
EndBASIC, gobasic |
|
| C# / .Net |
Blazor, System.Net.Http.HttpClient, Uno Platform |
Extism PDK for .NET, Spin SDK for .NET, wasi-experimental-http, wasi-http |
| C / C++ |
Emscripten, xxhr |
Extism PDK for C, httpclient_wasmedge_socket, wasi-experimental-http, wasi-http |
| Crystal |
crystal-js |
|
| Dart |
package:http, package:web, fetch_api, fetch_client |
|
| Golang / TinyGo |
net/http, wasm-fetch, Nigel2392/requester, Anko, Risor, Tengo, Vugu, Yaegi |
Capsule, Extism PDK for Go, go-plugin, Spin SDK for Go, stealthrocket/net, wasi-experimental-http, wasi-http, Wasm Workers Server |
| Haskell |
Extism PDK for Haskell |
|
| Java |
Bytecoder |
spin-teavm-example |
| JavaScript |
Goja, gojax/fetch, libcurl.js, Otto, quickjs-emscripten, sebastianwessel/quickjs |
WasmEdge-QuickJs, Extism PDK for JS, Spin SDK for JS / TS, Wasm Workers Server |
| Kotlin |
Kotlin/Wasm |
|
| Lisp |
Janet |
|
| Lua |
Wasmoon, gluahttp, lmodhttpclient, gopher-lua-libs, Pluto |
|
| PHP |
php-wasm |
|
| Pascal |
Free Pascal |
|
| Perl |
WebPerl |
|
| Python |
RustPython, Pyodide, pyodide-http, GPython, JupyterLite, PyScript, Panel, RPython, requests-wasm-polyfill, Stlite, urllib3, micropython-wasm |
componentize-py, Spin SDK for Python |
| R |
webR |
|
| Ruby |
ruby.wasm |
|
| Rust |
wasm-bindgen, Cloudflare Workers SDK, ehttp, gloo_net, httpc, http-client, iced, leptos, reqwasm, reqwest, sauron, seed, surf, sycamore Scripting: Rune |
reqwest, http_req, Extism PDK for Rust, Spin SDK for Rust, wasi-experimental-http, wasi-http, Wasm Workers Server |
| Starlark |
starlark-go, starlark-go-nethttp, starlib, starlight, starlight-enhanced |
|
| Swift |
SwiftWasm |
|
| Tcl |
criTiCaL, Wacl |
|
| Wonkey |
Wonkey/httprequest |
|
| Zig |
Extism PDK for Zig, Spin SDK for Zig, wasi-experimental-http |
|
| Misc langs |
MoonBit: Extism PDK for MoonBit, Virgil: Extism PDK for Virgil |
Browser WASM runtimes and V8-based runtimes like Node.js and Deno, also Bun
Ada
| Product / Implementation | TLDR: Usage | TLDR: Example code | Doc | Online demo | WASM Runtime | Internals: method to do real request |
|---|---|---|---|---|---|---|
|
Browser |
Manual JS |
AssemblyScript
| Product / Implementation | TLDR: Usage | TLDR: Example code | Doc | Online demo | WASM Runtime | Internals: method to do real request |
|---|---|---|---|---|---|---|
|
Browser, Node.js, and Deno |
JS |
BASIC
| Product / Implementation | TLDR: Usage | TLDR: Example code | Doc | Online demo | WASM Runtime | Internals: method to do real request |
|---|---|---|---|---|---|---|
|
Type |
Browser |
Using reqwest for API calls in REPL |
|||
|
Uses
Golang's |
C#
| Product / Implementation | TLDR: Usage | TLDR: Example code | Doc | Online demo | WASM Runtime | Internals: method to do real request |
|---|---|---|---|---|---|---|
|
Demo by JasonWatmore Demo source |
Browser, also native server-side |
JS |
|||
|
Standard library |
|
JS |
||||
|
Browser |
JS Interop invokes the TS
wrapper for |
C / C++
| Product / Implementation | TLDR: Usage | TLDR: Example code | Doc | Online demo | WASM Runtime | Internals: method to do real request |
|---|---|---|---|---|---|---|
|
Browser |
JS |
||||
|
Crystal
| Product / Implementation | TLDR: Usage | TLDR: Example code | Doc | Online demo | WASM Runtime | Internals: method to do real request |
|---|---|---|---|---|---|---|
|
Browser, Node.js, and Deno |
Manual JS |
Dart
| Product / Implementation | TLDR: Usage | TLDR: Example code | Doc | Online demo | WASM Runtime | Internals: method to do real request |
|---|---|---|---|---|---|---|
|
Browser with Wasm-GC support enabled[^browser-with-wasm-gc] |
JS |
||||
|
Browser with Wasm-GC support enabled[^browser-with-wasm-gc] |
Extends the
|
||||
|
Browser with Wasm-GC support enabled[^browser-with-wasm-gc] |
JS |
||||
|
Browser with Wasm-GC support enabled[^browser-with-wasm-gc] |
Direct |
Golang
| Product / Implementation | TLDR: Usage | TLDR: Example code | Doc | Online demo | WASM Runtime | Internals: method to do real request |
|---|---|---|---|---|---|---|
|
Browser and Node.js |
|||||
|
Save 4 MB of wasm binary size |
|
Browser and Node.js |
Direct JS |
|||
|
Browser and maybe Node.js |
Uses
Golang's |
||||
|
UI library |
|
Possible with Dev Container |
Browser |
Has no built-in solutions, just directly invoking Golang's |
||
|
It's VM / interpreter |
|
Directly invoking
Golang's |
Golang-like languages
| Product / Implementation | TLDR: Usage | TLDR: Example code | Doc | Online demo | WASM Runtime | Internals: method to do real request |
|---|---|---|---|---|---|---|
|
Browser and maybe Node |
Directly invoking
Golang's |
||||
|
Browser and maybe Node | |||||
|
for Tengo |
|
Java / JVM
| Product / Implementation | TLDR: Usage | TLDR: Example code | Doc | Online demo | WASM Runtime | Internals: method to do real request |
|---|---|---|---|---|---|---|
|
transpile JVM bytecode to Wasm |
|
Browser, Node.js, and Deno |
JavaScript
Using browser's own JavaScript VM
Possible, but why?
Libraries to use from JavaScript
| Product / Implementation | TLDR: Usage | TLDR: Example code | Doc | Online demo | WASM Runtime | Internals: method to do real request |
|---|---|---|---|---|---|---|
|
Requires server-side counterpart |
|
Browser |
Tunneling TCP to WebSocket using protocols "wisp" or "wsproxy" . |
JavaScript VM or interpreter compiled to WASM
JavaScript built with Emscripten
| Product / Implementation | TLDR: Usage | TLDR: Example code | Doc | Online demo | WASM Runtime | Internals: method to do real request |
|---|---|---|---|---|---|---|
|
JS |
|||||
|
Wrapper over quickjs-emscripten,
uses host function |
JavaScript implemented in Golang
| Product / Implementation | TLDR: Usage | TLDR: Example code | Doc | Online demo | WASM Runtime | Internals: method to do real request |
|---|---|---|---|---|---|---|
|
Using
Golang's |
|||||
|
Injecting a custom function into JS.
That func uses the goproxy as HTTP client,
which is a wrapper for Golang's |
|||||
|
Using
Golang's |
Kotlin
| Product / Implementation | TLDR: Usage | TLDR: Example code | Doc | Online demo | WASM Runtime | Internals: method to do real request |
|---|---|---|---|---|---|---|
|
still Alpha |
|
Browser with Wasm-GC and Wasm-Exception-Handling support enabled[^browser-with-wasm-gc], Node v21 and above, Deno v1.38 and above. |
Direct |
Lisp
Clojure-like languages
| Product / Implementation | TLDR: Usage | TLDR: Example code | Doc | Online demo | WASM Runtime | Internals: method to do real request |
|---|---|---|---|---|---|---|
|
Browser and maybe Node |
JS |
Lua
| Product / Implementation | TLDR: Usage | TLDR: Example code | Doc | Online demo | WASM Runtime | Internals: method to do real request |
|---|---|---|---|---|---|---|
|
Direct |
Lua implemented in Golang
| Product / Implementation | TLDR: Usage | TLDR: Example code | Doc | Online demo | WASM Runtime | Internals: method to do real request |
|---|---|---|---|---|---|---|
|
Browser and maybe Node | |||||
|
Browser and maybe Node | |||||
|
erdian718/lmodhttpclient aka ofunc/lmodhttpclient |
|
Browser and maybe Node |
Lua dialects
| Product / Implementation | TLDR: Usage | TLDR: Example code | Doc | Online demo | WASM Runtime | Internals: method to do real request |
|---|---|---|---|---|---|---|
|
Browser and maybe Node. |
JS |
PHP
| Product / Implementation | TLDR: Usage | TLDR: Example code | Doc | Online demo | WASM Runtime | Internals: method to do real request |
|---|---|---|---|---|---|---|
|
Fork of PIB |
|
|
Browser, Bun, Deno, Node, and CloudFlare Workers. |
Manual JS |
Pascal
| Product / Implementation | TLDR: Usage | TLDR: Example code | Doc | Online demo | WASM Runtime | Internals: method to do real request |
|---|---|---|---|---|---|---|
|
Browser and maybe Node |
Direct |
Perl
| Product / Implementation | TLDR: Usage | TLDR: Example code | Doc | Online demo | WASM Runtime | Internals: method to do real request |
|---|---|---|---|---|---|---|
|
Browser, Node.js, and Deno |
Manual JS |
Python
| Product / Implementation | TLDR: Usage | TLDR: Example code | Doc | Online demo | WASM Runtime | Internals: method to do real request |
|---|---|---|---|---|---|---|
|
Browser, Node.js, and maybe Deno | |||||
Also note that the pyodide-http is bundled in Pyodide. |
Browser, Node.js, and maybe Deno | |||||
|
|
Browser and maybe Node.js |
JS |
|||
|
Since 2.2.0 |
|
Browser only (yet) |
JS |
|||
|
||||||
|
Browser |
Uses pyodide's facilities |
||||
|
Browser |
Employs koenvo/pyodide-http. Also direct |
||||
|
Browser |
Employing |
||||
|
For pyjs |
|
Browser |
Direct |
|||
|
Browser and Node.js |
Direct |
||||
|
a port of Streamlit to Wasm |
|
Browser |
Uses pyodide's facilities. |
Python-like languages
| Product / Implementation | TLDR: Usage | TLDR: Example code | Doc | Online demo | WASM Runtime | Internals: method to do real request |
|---|---|---|---|---|---|---|
|
It's compiler |
|
Browser, Node.js, and Deno |
Direct |
R
| Product / Implementation | TLDR: Usage | TLDR: Example code | Doc | Online demo | WASM Runtime | Internals: method to do real request |
|---|---|---|---|---|---|---|
|
Browser and Node |
Implemented |
Ruby
| Product / Implementation | TLDR: Usage | TLDR: Example code | Doc | Online demo | WASM Runtime | Internals: method to do real request |
|---|---|---|---|---|---|---|
|
Direct JS |
Rust
| Product / Implementation | TLDR: Usage | TLDR: Example code | Doc | Online demo | WASM Runtime | Internals: method to do real request |
|---|---|---|---|---|---|---|
|
Prints to browser console, source |
|||||
|
JS |
|||||
|
Browser, Node.js, and Deno.
Also native |
JS |
||||
|
Browser, Node.js, and Deno.
Also native |
JS |
||||
|
Browser, Node.js, and Deno Also native (and others). |
JS |
||||
|
Browser, Node.js, and Deno |
JS |
||||
|
Browser |
Has no built-in solutions, just uses any suitable 3rd-party lib, such as: reqwest. |
||||
|
Browser Also server-side rendering (SSR) |
Has no built-in solutions, just uses any suitable 3rd-party lib, such as: reqwest, gloo_net, reqwasm. |
||||
|
Browser, Node.js, and Deno
Also native |
JS |
||||
|
Browser, Node.js, and Deno |
Wrapper for gloo_net |
||||
|
Browser
Also server-side rendering (SSR) |
JS |
||||
|
Browser, Node.js, and Deno |
JS |
||||
|
Browser, Node.js, and Deno
Also native |
Uses http-rs/http-client as WASM backend |
||||
|
Browser |
Has no built-in solutions, just uses any suitable 3rd-party lib, such as: reqwasm. |
Scripting languages for Rust
| Product / Implementation | TLDR: Usage | TLDR: Example code | Doc | Online demo | WASM Runtime | Internals: method to do real request |
|---|---|---|---|---|---|---|
|
Browser |
Uses reqwest. |
Starlark
| Product / Implementation | TLDR: Usage | TLDR: Example code | Doc | Online demo | WASM Runtime | Internals: method to do real request |
|---|---|---|---|---|---|---|
|
Using
Golang's |
|||||
|
||||||
|
"Starlark's missing stdlib" |
|
|||||
|
Using
Golang's |
|||||
|
Maintained fork of Starlight |
|
Using
Golang's |
Swift
| Product / Implementation | TLDR: Usage | TLDR: Example code | Doc | Online demo | WASM Runtime | Internals: method to do real request |
|---|---|---|---|---|---|---|
|
Browser, Node.js, and Deno |
Direct |
Tcl
| Product / Implementation | TLDR: Usage | TLDR: Example code | Doc | Online demo | WASM Runtime | Internals: method to do real request |
|---|---|---|---|---|---|---|
|
Uses
Golang's |
|||||
Needs a JavaScript-side function registered using
|
Browser |
Manual JS |
Wonkey
| Product / Implementation | TLDR: Usage | TLDR: Example code | Doc | Online demo | WASM Runtime | Internals: method to do real request |
|---|---|---|---|---|---|---|
|
Browser |
JS |
Standalone and server-side runtimes (mostly WASI and WASI-Socket-enabled), incl containers, FaaS, Edge Computing, etc
AssemblyScript
| Product / Implementation | TLDR: Usage | TLDR: Example code | Doc | Online demo | WASM Runtime | Internals: method to do real request |
|---|---|---|---|---|---|---|
|
Dev Container created by brendandburns |
Wasmtime with integrated |
Importing npm package which calls imported host function implemented in wasi-experimental-http-wasmtime Wasmtime's WASI module. |
|||
|
<-- |
Readme from dev-wasm-ts |
Possible with Dev Container created by brendandburns |
Wasmtime with integrated |
Using client lib which calls imported host function implemented in wasi-experimental-http-wasmtime Wasmtime's WASI module. |
|
|
implementations: |
|
Dev Container by brendandburns |
|
|
C# / .Net
| Product / Implementation | TLDR: Usage | TLDR: Example code | Doc | Online demo | WASM Runtime | Internals: method to do real request |
|---|---|---|---|---|---|---|
|
Calling
C-level-imported
runtime's host function
exported for plugins,
which makes actual request using |
|||||
|
C level
binding to |
|||||
|
Dev Container created by brendandburns |
Wasmtime with integrated |
Calling imported via C level bindings the host function implemented in wasi-experimental-http-wasmtime Wasmtime's WASI module. |
|||
|
implementations: |
|
Dev Container by brendandburns |
|
Sequence: .Net -> C -> WASI Calling
imported
C-level
Mono binding
which calls
generated
(by
|
C / C++
| Product / Implementation | TLDR: Usage | TLDR: Example code | Doc | Online demo | WASM Runtime | Internals: method to do real request |
|---|---|---|---|---|---|---|
|
Calling
C-level-imported
runtime's host function
exported for plugins,
which makes actual request using |
|||||
|
Raw socket write using WasmEdge Socket SDK for C/C++, which imports Wasmedge's implementation of WASI Socket |
|||||
|
Dev Container created by brendandburns |
Wasmtime with integrated |
Calling imported host function implemented in wasi-experimental-http-wasmtime Wasmtime's WASI module. |
|||
|
implementations: |
// snippet, expand it for full code
types_outgoing_request_t request = types_new_outgoing_request(
&method, &path, &query, &scheme, &domain, headers);
response = default_outgoing_http_handle(request, NULL);
types_future_incoming_response_get(response, &result);
types_incoming_response_consume(result.val.ok, &stream);
streams_read(stream, len, &body_res, &err);
|
Dev Container by brendandburns |
|
Calling
a function generated
by
|
Golang (Tinygo)
| Product / Implementation | TLDR: Usage | TLDR: Example code | Doc | Online demo | WASM Runtime | Internals: method to do real request |
|---|---|---|---|---|---|---|
|
||||||
|
Extism uses Wasmtime |
Calling
C-level-imported
runtime's host function
exported for plugins,
which makes actual request using |
||||
|
go-plugin uses wazero |
Invoking the |
||||
|
C level
binding to |
|||||
|
Dev Container created by brendandburns |
Wasmtime with integrated |
Calling imported host function implemented in wasi-experimental-http-wasmtime Wasmtime's WASI module. |
|||
|
implementations: |
|
Dev Container by brendandburns needs plenty of RAM to compile (~4G), so may cause OOM on 2-core instance |
|
Sequence: Go -> C -> WASI Calling
a method
generated
by
|
||
|
Use |
|
Hotpatching on module import |
||||
|
Calling to Go-wrapped, to C-wrapped, to C-level imported host function which makes request using reqwest. |
Haskell
| Product / Implementation | TLDR: Usage | TLDR: Example code | Doc | Online demo | WASM Runtime | Internals: method to do real request |
|---|---|---|---|---|---|---|
|
Extism uses Wasmtime |
Calling
imported
runtime's host function
exported for plugins,
which makes actual request using |
Java
| Product / Implementation | TLDR: Usage | TLDR: Example code | Doc | Online demo | WASM Runtime | Internals: method to do real request |
|---|---|---|---|---|---|---|
|
Uses forked TeaVM as compiler. |
|
Direct invocation of imported Spin's host function. |
JavaScript and TypeScript
| Product / Implementation | TLDR: Usage | TLDR: Example code | Doc | Online demo | WASM Runtime | Internals: method to do real request |
|---|---|---|---|---|---|---|
|
Distinguished by URL scheme
raw socket write
to
(1) |
|||||
|
Extism uses Wasmtime |
|
||||
|
Invocation of bound JS SDK function, which calls via Rust Spin SDK Spin's host function. |
|||||
|
Invocation of bound JS SDK function, which calls via Rust Spin SDK Spin's host function. |
|||||
|
Calling
bound to JS
|
MoonBit
| Product / Implementation | TLDR: Usage | TLDR: Example code | Doc | Online demo | WASM Runtime | Internals: method to do real request |
|---|---|---|---|---|---|---|
|
Extism Plug-in Development Kit (PDK) for MoonBit Experimental |
|
Calling
imported
runtime's host function
exported for plugins,
which makes actual request using |
Python
| Product / Implementation | TLDR: Usage | TLDR: Example code | Doc | Online demo | WASM Runtime | Internals: method to do real request |
|---|---|---|---|---|---|---|
|
Wasmtime version 15.0, maybe incl. Spin. |
Genetaring Python bindings to wasi-http based on wit files under the scenes during |
||||
|
A Python |
Rust
| Product / Implementation | TLDR: Usage | TLDR: Example code | Doc | Online demo | WASM Runtime | Internals: method to do real request |
|---|---|---|---|---|---|---|
|
Possible with Dev Container by brendandburns |
Calling
C-level-imported
runtime's host function
exported for plugins,
which makes actual request using |
||||
|
Writes to
|
|||||
|
Calling imported Spin's host function. |
|||||
|
as part of Any code based on WasmEdge's forks of tokio-rs or mio is expected to work in Wasmedge runtime |
|
Wrapping internal stream with WasmEdgeTls, which is built on top of WasmEdge's implementation of WASI Socket. |
||||
|
Wasmtime with integrated |
Calling imported Wasmtime's host function. The actual request is here. |
||||
|
implementations: |
|
Possible with Dev Container by brendandburns |
|
Rust code
generated
(by
|
||
|
Calling imported host function which makes request using reqwest. |
Virgil
| Product / Implementation | TLDR: Usage | TLDR: Example code | Doc | Online demo | WASM Runtime | Internals: method to do real request |
|---|---|---|---|---|---|---|
|
Calling
C-level-imported
runtime's host function
exported for plugins,
which makes actual request using |
Zig
| Product / Implementation | TLDR: Usage | TLDR: Example code | Doc | Online demo | WASM Runtime | Internals: method to do real request |
|---|---|---|---|---|---|---|
|
Extism uses Wasmtime |
Calling
imported
runtime's host function
exported for plugins,
which makes actual request using |
||||
|
Unofficial |
|
Calling to C-level import of Spin's host function. |
||||
|
Dev Container by brendandburns |
Wasmtime with integrated |
Calling imported Wasmtime's host function. The actual request is here. |
[^browser-with-wasm-gc]: Firefox 120+, and all based on Chrome(ium) 119+.