Skip to main content

Introduction to Nostr

Nostr ("Notes and Other Stuff Transmitted by Relays") is an open protocol for publishing signed messages. It is not an app or a company. Like email or HTTP, it is a shared format that many independent programs speak, so a post written in one Nostr app can be read in any other.

Clients connect to several relays over WebSockets

The three parts​

  • Events are signed JSON objects. A post, a profile, a like, a follow list: each is an event. Anyone can check an event's signature, so nobody has to trust the server that delivered it.
  • Relays are WebSocket servers that store events and answer queries. They don't talk to each other. Anyone can run one, and each relay sets its own rules.
  • Clients are the apps people use. They sign events with the user's key, send them to a few relays, and query relays for events to show.

That is the whole core protocol, defined in NIP-01. Everything else (replies, DMs, zaps, long-form articles) is a convention on top, written up as a NIP (Nostr Implementation Possibility).

Why developers use it​

  • Identity is a key pair. There's no account server. The same key works in every Nostr app, and no operator can take it away. The flip side: there's no password reset either.
  • Data moves with the user. Posts, follows and profile are events the user signed. Any client can fetch them from any relay that has them.
  • No single point of control. If one relay blocks you, publish to others. Clients usually read from and write to several.
  • The core is small. One data type, three client messages, five relay messages. You can talk to a relay with a raw WebSocket and about fifty lines of code (Relay communication shows how).

Keys, briefly​

A Nostr identity is a secp256k1 key pair. Inside events and filters, keys are always 64-character lowercase hex. The npub1… and nsec1… strings you see in apps are the same keys in bech32 form (NIP-19). They are for showing to and copying from humans only, and never go inside an event. Keys and signing covers both forms and how to keep a secret key safe.

Where to start​

  1. How Nostr works: the architecture and how a message travels.
  2. Keys and signing: identity, key formats and signers.
  3. Build your first app: a small web client that reads and posts notes, tested against current libraries.

If you prefer the command line, the wiki's Quick start gets you from nothing to a published event with nak in five minutes.

Specs and community​