NostrAccess (nostr_access v0.3.3)
View Sourcenostr_access - Elixir library for querying Nostr relays with caching and deduplication.
Features
- Query multiple Nostr relays simultaneously
- Automatic event deduplication following NIP-01 rules
- In-memory caching with configurable TTL
- Connection pooling with automatic reconnection
- Both synchronous (
fetch/3) and asynchronous (stream/3) APIs
Quick Start
# Fetch events from a single relay
{:ok, events} = Nostr.Client.fetch(["wss://relay.example.com"], %{kinds: [1]})
# Stream events from multiple relays
{:ok, ref} = Nostr.Client.stream(["wss://relay1.com", "wss://relay2.com"], %{authors: ["pubkey"]})
# Receive events
receive do
{:nostr_event, ^ref, event} -> event
{:nostr_eose, ^ref, true} -> :done
endConfiguration
config :nostr_access,
idle_ms: 5000,
overall_timeout: 30_000,
cache?: true,
dedup_strategy: Nostr.Dedup.DefaultArchitecture
The library uses a supervision tree with:
- Connection pools (≤3 connections per relay)
- Subscription limits (≤10 subscriptions per connection)
- Automatic idle timeout after REQs are sent (5000ms default)
- Cache with TTL (2h for events, 10min for misses)
Summary
Functions
Returns the version of nostr_access.