Nostr Read
AI-generatedOverview
This node reads events from Nostr relays using various filtering strategies. It connects to one or more specified Nostr relays and fetches events based on user-defined criteria such as public key, event ID, hashtags, mentions, text search, raw filters, or encrypted direct messages (NIP-04). The node supports time-based filtering with relative or absolute date ranges.
Common scenarios include:
- Retrieving all events authored by a specific user.
- Searching for events containing a particular hashtag or mention.
- Fetching a specific event by its ID.
- Performing advanced queries using raw JSON filters.
- Decrypting encrypted direct messages if the user provides the necessary secret key credential.
- Searching notes containing certain keywords on relays supporting NIP-50.
Practical examples:
- Monitoring posts from a public key to track updates.
- Collecting all events tagged with a hashtag like "#foodstr" for content aggregation.
- Fetching a conversation by decrypting direct messages sent to the user.
- Searching for mentions of a user in events.
- Using raw filters to perform complex queries combining multiple conditions.
Properties
| Name | Meaning |
|---|---|
| Strategy | Filter method to use. Options: Encrypted Direct Message (nip-04), EventId, Hashtag, Mention, RawFilter (advanced), Text Search, UserPublickey. |
| Pubkey | Target user's public key (used when strategy is "pubkey"). |
| EventId | Target event ID (used when strategy is "eventid"). Supports relay metadata to send requests to additional relays. |
| Search Word | Keyword to search within notes (used when strategy is "textSearch"). Requires relays supporting NIP-50. |
| Hashtag | Hashtag string to search for (used when strategy is "hashtag"). |
| Raw Filter(advanced) | Raw JSON filter object for advanced querying (used when strategy is "rawFilter"). The since and until values are overwritten by form values. |
| Mention | Public key of the person mentioned (used when strategy is "mention"). |
| Relative | Boolean indicating whether to use relative time filtering (true) or absolute dates (false). Hidden when strategy is "eventid". |
| From | Number of days/hours/minutes ago from now to start fetching events (used when relative is true). Hidden when strategy is "eventid". |
| Unit | Time unit for "From" property: Day, Hour, or Minute. Hidden when strategy is "eventid". |
| Since | Absolute start datetime for fetching events (used when relative is false). Hidden when strategy is "eventid". |
| Until | Absolute end datetime for fetching events (used when relative is false). Hidden when strategy is "eventid". |
| Custom Relay | Comma-separated list of WebSocket relay URLs to connect to. Defaults to a predefined set of public relays. |
| Error With Empty Result | Whether to throw an error if no events are found matching the query. |
Additional notices appear when selecting the "nip-04" strategy:
- Warning that NIP-04 is deprecated and leaks metadata; should only be used with AUTH-enabled relays.
- Notice that NIP-04 requires API credentials (a secret key) to decrypt messages.
Output
The node outputs an array of event objects in the json field. Each event contains standard Nostr event properties such as:
id: Event identifier.pubkey: Public key of the event author.created_at: Timestamp of event creation.kind: Event kind/type.content: Event content (decrypted if applicable).- Other event tags and metadata.
If the strategy is "nip-04" and decryption is successful, the event's content field will contain the decrypted message, along with additional flags:
decrypted: Boolean indicating successful decryption.decryptionError: Error message if decryption failed.counterpart: Public key of the other party in the encrypted message.
Events are sorted by creation time descending (newest first).
The node does not output binary data.
Dependencies
- Connects to Nostr relays via WebSocket URLs provided by the user or defaults.
- For "nip-04" strategy, requires an API key credential containing a secret key to decrypt messages.
- Uses external libraries for cryptographic operations and Nostr protocol handling.
- Relays must support relevant NIPs depending on the strategy (e.g., NIP-50 for text search).
- The user must configure appropriate relay URLs and credentials in n8n.
Troubleshooting
- Empty results: If no events match the filter and "Error With Empty Result" is enabled, the node throws an error. To avoid this, disable that option or adjust filters.
- Invalid secret key: For "nip-04" strategy, if the secret key credential is missing or invalid, the node throws an error indicating an invalid secret key.
- Relay support: Text search requires relays supporting NIP-50; otherwise, the node throws an error asking to set at least one supported relay.
- Decryption failures: Encrypted messages may fail to decrypt due to incorrect keys or relay issues; these events will have a decryption error message but still appear in output.
- Relay connection issues: Ensure relay URLs are correct and reachable over WebSocket.
- Deprecated NIP-04: Users are warned that NIP-04 is deprecated and leaks metadata; consider using newer standards for sensitive communications.