Read the native nostr events guide. Signatures below come from the published SDK declarations. Access SDK services through db; use their constructors only when integrating at a lower level.
NostrbaseEvents
/** Escape hatch for standard Nostr kinds, filters, profiles, and protocol-specific apps. */
declare class NostrbaseEvents {}
constructor
constructor(client: EventHost);
search
/** NIP-50 search. Results depend on the configured relays' search support. */
search(
query: string,
filter?: Filter,
options?: {
signal?: AbortSignal;
},
): Promise<Result<NostrEvent[]>>;
query
query(
filter: Filter | Filter[],
options?: {
signal?: AbortSignal;
},
): Promise<Result<NostrEvent[]>>;
publish
publish(
template: EventTemplate,
options?: {
signal?: AbortSignal;
},
): Promise<Result<NostrEvent>>;
publishSigned
publishSigned(
event: NostrEvent,
options?: {
signal?: AbortSignal;
},
): Promise<Result<NostrEvent>>;
subscribe
subscribe(
filter: Filter | Filter[],
callback: (event: NostrEvent) => void,
onError?: (error: NostrbaseError) => void,
): {
unsubscribe(): void;
};
Supporting declarations
These types appear in public signatures but are not package exports.
EventHost
interface EventHost {
relays: string[];
transport: Transport;
minWriteAcks: number;
request(filters: Filter[], signal?: AbortSignal): Promise<TransportRead>;
sign(template: EventTemplate): Promise<NostrEvent>;
publish(event: NostrEvent, signal?: AbortSignal): Promise<WriteReceipt>;
ingest(event: NostrEvent): boolean;
assertOpen(): void;
trackEventSubscription(dispose: () => void): () => void;
}