Nostr Write icon

Nostr Write

Consume Nostr API

Actions4

  • Event(advanced) Actions
  • Raw Json Event(advanced) Actions
  • Encrypted Direct Message(nip-04) Actions
  • BasicNote Actions

Overview

This node allows users to create and send Nostr protocol events, specifically focusing on the "BasicNote" resource with the "Send" operation. It is designed to publish notes or messages to one or multiple Nostr relays over WebSocket connections. The node supports different event types including simple notes, encrypted direct messages (NIP-04), advanced custom events, and raw JSON events.

Typical use cases include:

  • Publishing a public note or message to the Nostr network.
  • Sending an encrypted direct message to a specific recipient using NIP-04 encryption.
  • Creating and sending customized events with specific kinds and tags.
  • Sending pre-constructed raw JSON events directly.

For example, a user can input a text note and have it broadcasted to several Nostr relays, making it visible to other clients connected to those relays.

Properties

Name Meaning
Content The main text content of the note or message to send.
EventId Hexadecimal event ID, used when manually specifying event details in advanced mode.
Pubkey Hexadecimal public key associated with the event, required for advanced event sending.
Sig Signature string of the event, used for verifying authenticity in advanced mode.
CreatedAt Unix timestamp indicating when the event was created, used in advanced mode.
Custom Relay Comma-separated list of WebSocket relay URLs where the event will be sent. Defaults to popular relays.

Output

The node outputs an array of objects, each containing:

  • event: The event object that was sent, including all its properties such as content, kind, tags, id, pubkey, signature, and creation time.
  • sendResults: An array of results from sending the event to each specified relay, indicating success or failure per relay.

If binary data were involved (not in this case), it would typically represent attachments or encrypted payloads, but here the output is purely JSON-based event data.

Dependencies

  • Requires an API authentication token or secret key credential to sign events.
  • Uses the nostr-tools library for event finalization and NIP-04 encryption.
  • Uses WebSocket connections to communicate with Nostr relays.
  • Relays must support the Nostr protocol over WebSocket.
  • No additional environment variables are explicitly required beyond the API key credential.

Troubleshooting

  • Invalid secret key error: If the provided secret key is missing or malformed, the node throws an error. Ensure the secret key is correctly configured and formatted.
  • Invalid tags error: When sending advanced events, tags must be a valid JSON array. Invalid JSON or non-array inputs cause errors. Validate tag format before input.
  • JSON parse failure: For raw JSON events, invalid JSON strings will cause parsing errors. Verify JSON syntax carefully.
  • Relay connection issues: If relays are unreachable or reject the event, sending may fail silently or return errors in sendResults. Check relay URLs and network connectivity.
  • Encryption errors: For NIP-04 encrypted messages, ensure the recipient's public key is valid and the secret key is correct; otherwise, encryption will fail.

Links and References

Discussion