Docs
Gateway HTTP API
slab-gateway serves Slab data over plain HTTP. Reads are open; uploads are optional and paid from the gateway's wallet.
Running a gateway
slab-gateway --listen 127.0.0.1:8080 # read-only, joins the testnet
slab-gateway --listen 127.0.0.1:8080 --wallet w.json # also accepts uploads
slab-gateway --site <owner>/<topic> # serve a feed as a website at /
| Option | Meaning |
|---|---|
--listen | HTTP address (default 127.0.0.1:8080) |
--peer | bootstrap node (repeatable); default: the public testnet |
--wallet | wallet to pay uploads from; enables POST /slab |
--site | serve a feed’s directory at /; the link paste page moves to /gateway |
Reading
| Method and path | Returns |
|---|---|
GET /slab/{ref}/ | a directory’s index.html, or the file itself |
GET /slab/{ref}/{path} | a file inside a directory, with its content type |
GET /feeds/{owner}/{topic} | the feed’s current {"seq", "reference"} |
GET /feeds/{owner}/{topic}/{path} | what the feed points at, like /slab |
GET /v0/file/{root}?key=<hex>[&name=<file>] | the original form; name sets Content-Disposition |
GET /healthz | ok |
- Ranges. Every read supports one HTTP
Range(206withContent-Range,416if unsatisfiable) and fetches only the slabs it covers, so video seeking works. - Errors. A fetch that fails on the network gives
502. - Isolation. Content under
/slabis served withContent-Security-Policy: sandbox allow-scripts allow-forms allow-popups allow-downloadsandX-Content-Type-Options: nosniff: sites run without the gateway’s origin, so they can’t read each other’s storage or call the upload API.
Uploading
Only with --wallet. Each upload is paid from that wallet, one voucher per slab.
| Method and path | Does |
|---|---|
POST /slab?name=<file name> | store the body as a one-file directory → 201 {"reference": "<128 hex>"} |
curl -X POST --data-binary @photo.jpg \
-H "Authorization: Bearer $(cat w.json.token)" \
-H "Content-Type: image/jpeg" \
"http://127.0.0.1:8080/slab?name=photo.jpg"
- Auth.
Authorization: Bearer <token>; the token is created on first start in<wallet>.token(0600). TheHostheader must name the gateway’s listen address. Together these stop web pages you visit from spending the wallet (no CORS preflight passes, and DNS rebinding fails the Host check). - Size. A
Content-Lengthis required (vouchers are taken up front;411without it), up to about 2 GiB (413above). Bodies are streamed to the network; a 300 MB upload peaked at 27 MiB of gateway memory. - Uploads run one at a time. Tar collections (
POST /slabwithapplication/x-tar) aren’t supported; upload directories withslab put <dir>.