{"id":"da179d8306fd26e7bbe80c974ee9d8b6480fb16feeffe2df44f5896535a07fc7","pubkey":"44a3a93660c84b21006efd96da8e9dd728abda4853371584c5b15c1a1eedf548","created_at":1772182765,"kind":30817,"tags":[["d","nip-30402"],["title","NIP-30402: L402 Service Registry"],["summary","Standard Nostr event kind for publishing and discovering L402-enabled API services. Enables permissionless, relay-based discovery of Lightning-native APIs for agents and humans."],["t","l402"],["t","lightning"],["t","api"]],"content":"# NIP-30402 — L402 Service Registry\n\n`draft` `optional`\n\n## Abstract\n\nThis NIP defines a standard Nostr event kind for publishing, discovering, and updating L402-enabled API service listings. Kind **30402** allows service operators — human or autonomous — to advertise their Lightning-native APIs on public Nostr relays. Clients can fetch, filter, and display these listings without a central registry.\n\n## Motivation\n\nL402 (HTTP 402 Payment Required + Lightning) enables machine-to-machine micropayments for API access. A decentralised, relay-based registry of L402 services allows:\n\n- **Agents** to discover APIs autonomously (no central index to trust)\n- **Operators** to publish and update their listings permissionlessly\n- **Clients** to aggregate across relays and rank by community signals\n\n## Event Kind\n\n| Kind  | Description |\n|-------|-------------|\n| 30402 | L402 Service Listing (addressable, replaceable per pubkey+d) |\n\n## Event Structure\n\n```json\n{\n  \"kind\": 30402,\n  \"pubkey\": \"<operator pubkey>\",\n  \"created_at\": <unix timestamp>,\n  \"content\": \"<markdown description of the service>\",\n  \"tags\": [\n    [\"d\", \"<unique-slug>\"],\n    [\"name\", \"<human-readable service name>\"],\n    [\"url\", \"<L402 API base URL>\"],\n    [\"docs\", \"<documentation URL>\"],\n    [\"category\", \"<category>\"],\n    [\"pricing\", \"<pricing_model>\"],\n    [\"sat\", \"<sats per call>\"],\n    [\"t\", \"l402\"],\n    [\"t\", \"<additional tag>\"]\n  ]\n}\n```\n\n## Tag Definitions\n\n| Tag       | Required | Description |\n|-----------|----------|-------------|\n| `d`       | ✅       | Unique slug identifier for this listing. Used as the replaceable event identifier. Must be stable — changing it creates a new listing. |\n| `name`    | ✅       | Human-readable name of the service. |\n| `url`     | ✅       | Base URL of the L402 API endpoint. |\n| `docs`    | ✅       | URL of the API documentation. |\n| `category`| ✅       | One of: `ai`, `data`, `media`, `compute`, `finance`, `storage`, `other`. |\n| `pricing` | ✅       | Pricing model: `per_call`, `subscription`, `metered`, `tiered`. |\n| `sat`     | ⬜       | Price per call in satoshis (integer string). Omit if pricing is not per-call. |\n| `t`       | ✅       | Must include `\"l402\"`. Additional topic tags optional. |\n\n## Categories\n\n| Value     | Description |\n|-----------|-------------|\n| `ai`      | AI inference, embeddings, generation |\n| `data`    | Data feeds, oracles, search |\n| `media`   | Image, video, audio processing |\n| `compute` | General computation, code execution |\n| `finance` | Financial data, payments, Bitcoin |\n| `storage` | File storage, CDN, IPFS |\n| `other`   | Anything not covered above |\n\n## Pricing Models\n\n| Value          | Description |\n|----------------|-------------|\n| `per_call`     | Fixed sats per API call. Include `sat` tag. |\n| `subscription` | Fixed recurring fee. Describe in `content`. |\n| `metered`      | Pay per unit (tokens, bytes, requests). Describe in `content`. |\n| `tiered`       | Multiple pricing levels. Describe tiers in `content`. |\n\n## Content Field\n\nThe `content` field SHOULD contain a Markdown description of the service including:\n- What the API does\n- Supported endpoints\n- Authentication flow (L402 challenge/response)\n- Usage examples (curl, agent prompt, etc.)\n- Any rate limits or constraints\n\n## Deletion\n\nTo delist a service, publish a NIP-09 deletion event (`kind: 5`) referencing the kind 30402 event by its `a` tag:\n\n```json\n{\n  \"kind\": 5,\n  \"tags\": [[\"a\", \"30402:<pubkey>:<d-tag>\"]]\n}\n```\n\n## Agent Submission Instructions\n\nAutonomous agents that wish to publish an L402 service listing MUST:\n\n1. Construct a kind 30402 event with all required tags.\n2. Sign the event with the operator's private key (NIP-01).\n3. Publish to at least 3 well-known relays (e.g. `wss://relay.damus.io`, `wss://nos.lol`, `wss://relay.primal.net`).\n\nExample (using `nak` CLI):\n\n```bash\nnak event \\\n  --kind 30402 \\\n  --tag d=my-api \\\n  --tag name=\"My L402 API\" \\\n  --tag url=\"https://api.example.com\" \\\n  --tag docs=\"https://docs.example.com\" \\\n  --tag category=ai \\\n  --tag pricing=per_call \\\n  --tag sat=10 \\\n  --tag t=l402 \\\n  --content \"## My L402 API\\n\\nDoes something useful for sats.\" \\\n  wss://relay.damus.io wss://nos.lol wss://relay.primal.net\n```\n\n## Human Submission (NIP-07)\n\nClients implementing an L402 Index SHOULD provide a web form that:\n\n1. Collects required fields from the user.\n2. Constructs the kind 30402 event client-side.\n3. Calls `window.nostr.signEvent(event)` (NIP-07) to sign.\n4. Publishes to relays via a WebSocket connection.\n\nThis allows submission without exposing private keys to the application.\n\n## Discovery\n\nClients SHOULD query relays for kind 30402 events using:\n\n```json\n{\"kinds\": [30402], \"#t\": [\"l402\"]}\n```\n\nTo filter by category:\n\n```json\n{\"kinds\": [30402], \"#category\": [\"ai\"]}\n```\n\n## Example Event\n\n```json\n{\n  \"kind\": 30402,\n  \"pubkey\": \"44a3a93660c84b21006efd96da8e9dd728abda4853371584c5b15c1a1eedf548\",\n  \"content\": \"## Lightning AI Inference\\n\\nGPT-4-class inference gated by L402. Pay 10 sats per 1k tokens.\",\n  \"tags\": [\n    [\"d\", \"lightning-ai-inference\"],\n    [\"name\", \"Lightning AI\"],\n    [\"url\", \"https://api.lightningai.example\"],\n    [\"docs\", \"https://docs.lightningai.example\"],\n    [\"category\", \"ai\"],\n    [\"pricing\", \"per_call\"],\n    [\"sat\", \"10\"],\n    [\"t\", \"l402\"],\n    [\"t\", \"ai\"]\n  ]\n}\n```\n\n## Implementations\n\n- [L402 Index](https://l402-index.netlify.app) — community directory fetching kind 30402 events\n\n## See Also\n\n- [NIP-31402](./NIP-31402.md) — SARA Revenue Share Offering Registry\n- [NIP-01](https://github.com/nostr-protocol/nostr/blob/master/01.md) — Basic protocol\n- [NIP-07](https://github.com/nostr-protocol/nostr/blob/master/07.md) — Browser signer\n- [NIP-09](https://github.com/nostr-protocol/nostr/blob/master/09.md) — Event deletion","sig":"777557fe9e160af8973522d2cc1f353b3b8582eb89179d7274b0fa1ece864634bec1ce0ab6847e1ed3f5f6f9197ad9c86fa6aa0a95b04b995c69cd3da9d95ac8"}