Skip to content

Instantly share code, notes, and snippets.

@nothingmuch
Created August 13, 2025 22:13
Show Gist options
  • Select an option

  • Save nothingmuch/95e4f902ede28da44d67158cf21a724f to your computer and use it in GitHub Desktop.

Select an option

Save nothingmuch/95e4f902ede28da44d67158cf21a724f to your computer and use it in GitHub Desktop.
Nostr OHTTP bridge

MVP

client <-https-> ohttp-relay <-https-> nostr-ohttp-gateway <-websocket-> nostr-relay

the client connects to the ohttp relay and POSTs OHTTP encapsulated requests encrypted to the nostr ohttp gateway.

the ohttp target resource is a REST nostr bridge, which maps NIP-01 functionality to HTTP.

client messages from NIP-01 all map to POST requests. publishing an event waits for an OK message which becomes the response. a new SUBSCRIBE message allocates a globally unique subscription ID for the OHTTP client, and begins streaming it using chunked OHTTP. REQ requests must use a bridge provided subscription id.

relay responses work as if clients used multiple websockets connections, with each connection either posting a single event or subscribing to a single request, but otherwise behave unchanged.

to simplify serialization, event data can be serialized on the wire in the format used for signing instead of as JSON objects, with a JSON object only included for any remaining NIP-24 fields as necessary.

Future directions

anonymous credentials for rate limiting and paid usage

multihop + async OHTTP,

PIR subscriptions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment