Repository navigation
Quick Start
Make a key, run a relay on your laptop, publish an event and read it back: first from the command line, then in JavaScript and Python. Every command on this page was run against nak v0.21.2, nostr-tools 2.25.2 and nostr-sdk 0.45.1 in October 2026.
If you ran the 60-second block on Home, skip to step 3.
nak is the Nostr army knife: one binary that signs, publishes, queries, decodes, and even runs a relay.
# Linux / macOS: downloads the latest release binary
curl -sSL https://raw.githubusercontent.com/fiatjaf/nak/master/install.sh | sh
# or, with Go installed
go install github.com/fiatjaf/nak@latest
nak --versionMore ways to install (Homebrew, AUR, Nix) are on the nak page.
nak serve
# > relay running at ws://localhost:10547It's an in-memory relay for development: nothing you publish leaves your machine, and it forgets everything when you stop it. Leave it running and open a second terminal.
# a throwaway 64-char hex secret key, kept out of your shell history
export NOSTR_SECRET_KEY=$(nak key generate)
# your public key, as hex and as npub1… (the secret goes in via
# stdin, so it never shows up in the process list)
echo "$NOSTR_SECRET_KEY" | nak key public
nak encode npub $(echo "$NOSTR_SECRET_KEY" | nak key public)nak picks up NOSTR_SECRET_KEY automatically, so you don't need to pass --sec on every command.
Caution
This is a throwaway test key. Never put a real nsec in a script, a CI log or your shell history. If you must use a real key with nak, type it without echo (see nak → Keys) or pass a bunker:// URL as --sec. In apps, sign through a signer.
nak event -c "hello nostr" ws://localhost:10547nak prints the signed event and publishing to ws://localhost:10547... success. That JSON is the whole protocol: an id, your pubkey, a created_at timestamp, a kind (1 = short text note), tags, content and a sig. Protocol basics explains each field.
nak req -k 1 -l 10 ws://localhost:10547req sends a subscription with a filter (-k kind, -a author, -l limit) and prints matching events. Now try the live network, read-only:
# three recent notes from two public relays
nak req -k 1 -l 3 wss://relay.primal.net wss://relay.nostr.net
# the relay's self-description (its NIP-11 info document)
nak relay wss://relay.primal.net
# a profile, found from a name@domain handle (NIP-05)
nak fetch fiatjaf.comJavaScript / TypeScript: nostr-tools
npm i nostr-tools// hello.mjs
import { generateSecretKey, getPublicKey, finalizeEvent } from 'nostr-tools/pure'
import { SimplePool } from 'nostr-tools/pool'
import * as nip19 from 'nostr-tools/nip19'
const relays = ['ws://localhost:10547']
// Uint8Array, keep it secret
const sk = generateSecretKey()
// hex public key
const pk = getPublicKey(sk)
console.log('npub:', nip19.npubEncode(pk))
const pool = new SimplePool()
// 1. publish a note
const event = finalizeEvent({
kind: 1,
created_at: Math.floor(Date.now() / 1000),
tags: [],
content: 'hello from nostr-tools',
}, sk)
await Promise.any(pool.publish(relays, event))
console.log('published', event.id)
// 2. read it back
const notes = await pool.querySync(relays, { kinds: [1], authors: [pk], limit: 10 })
console.log(notes.map(e => e.content))
pool.close(relays)node hello.mjsPython: nostr-sdk
pip install nostr-sdk# hello.py
import asyncio
from datetime import timedelta
from nostr_sdk import Client, EventBuilder, Filter, Keys, Kind, KindStandard, RelayUrl, ReqTarget
async def main():
keys = Keys.generate()
print("npub:", keys.public_key().to_bech32())
client = Client()
await client.add_relay(RelayUrl.parse("ws://localhost:10547"))
await client.connect()
# publish a note
note = EventBuilder(kind=Kind.from_std(KindStandard.TEXT_NOTE), content="hello from python").finalize(keys)
await client.send_event(note)
# read it back
f = Filter().author(keys.public_key()).kind(Kind.from_std(KindStandard.TEXT_NOTE)).limit(10)
events = await client.fetch_events(ReqTarget.auto([f]), timedelta(seconds=5))
for e in events:
print(e.content())
asyncio.run(main())The API is still marked alpha and changes between minor versions, so pin the version you test against.
Rust, Go, Kotlin, Swift, Dart…
-
Rust:
cargo add nostr-sdk, then follow the book at nostrdevkit.org (the project formerly called rust-nostr). -
Go:
go get fiatjaf.com/nostr@master(the successor to the archived go-nostr). -
Kotlin / Android: Quartz,
com.vitorpamplona.quartz:quartz:2.0.0(released Oct 2026). -
Swift: the Nostr Dev Kit Swift package,
nostrdevkit/nostr-sdk-swift. -
Dart / Flutter:
dart pub add ndk.
Install details and status for each are on Libraries.
- An event is signed JSON. Anyone can verify it, so relays don't need to be trusted.
- A relay is a WebSocket server that stores events and answers filters. You publish to several and read from several.
- A client is any code that signs, publishes and queries. You just wrote two.
Tip
Where next? Build a client turns this into a real feed: signer login, profiles, the outbox model, replies and likes. Protocol basics is the reference for kinds, tags and messages.
← Home · Next: Build a client →
Nostr Developer Guide · maintained by the W3C Nostr Community Group (a Community Group work, not a W3C Standard) · last reviewed 22 October 2026 · report a problem · guide site