npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@nostrwatch/nostrawl

v0.2.0

Published

A nostr library for continously retrieving events from nostr relays based on a set of filters.

Readme

nostrawl

Queue-based Nostr relay web crawler with PQueue and BullMQ adapters.

npm version License Status Runtime

Overview

nostrawl wraps nostr-fetch with pluggable queue adapters for controlled, rate-limited crawling of Nostr relay (a WebSocket server that stores and forwards events) data. Given a list of relay URLs and a Nostr filter (a query object specifying event kinds, authors, or time ranges), nostrawl distributes fetch jobs across in-memory (PQueue) or Redis-backed (BullMQ) queues, deduplicates events via LMDB cache, and emits each new event to registered listeners. It is designed for persistent, long-running crawl processes that must survive restarts without reprocessing previously seen events.

Prerequisites

Node.js >=20 and pnpm >=9.

For BullMQ adapter: a running Redis instance (tested with Redis 7+).

Installation

pnpm add nostrawl

Or with npm:

npm install nostrawl

Quick Start

import {nostrawl} from 'nostrawl'

const trawler = nostrawl(
  ['wss://relay.damus.io', 'wss://nos.lol'],
  {
    filters: {kinds: [1]},
    cache: {enabled: true, path: './cache'},
    logLevel: 'info'
  }
)

trawler.on('event', (event) => {
  console.log('received event:', event.id)
})

trawler.on('progress', (progress) => {
  console.log(`relay ${progress.relay}: found=${progress.found} rejected=${progress.rejected}`)
})

await trawler.run()

API

nostrawl(relays, options?)

function nostrawl(relays: string[], options?: Partial<TrawlerOptions>): PQueueAdapter

Creates and initializes a trawler using the PQueue adapter. Returns the adapter instance, which extends EventEmitter.

| Parameter | Type | Description | |-----------|------|-------------| | relays | string[] | Array of relay WebSocket URLs to crawl | | options | Partial<TrawlerOptions> | Optional configuration — see options table below |

TrawlerOptions

| Option | Type | Default | Description | |--------|------|---------|-------------| | filters | Record<string, any> | {} | Nostr filter object passed to nostr-fetch | | since | number \| Record<string, number> | 0 | Unix timestamp; per-relay timestamps accepted | | adapter | 'pqueue' \| 'bullmq' | 'pqueue' | Queue backend. BullMQ requires Redis | | relaysPerBatch | number | 3 | Number of relays processed concurrently per job | | repeatWhenComplete | boolean | true | Restart crawl after all relays finish | | restDuration | number | 1000 | Milliseconds to wait before restarting (if repeat enabled) | | progressEvery | number | 5000 | Minimum ms between progress events per relay | | cache.enabled | boolean | true | Deduplicate events using LMDB cache | | cache.path | string | './cache' | Directory path for LMDB cache | | logLevel | LogLevel | 'info' | Logging verbosity | | validator | (trawler, event) => boolean | — | Return false to reject an event before emitting | | parser | (trawler, event, job) => Promise<void> | — | Legacy per-event callback; prefer on('event', ...) |

Events

The returned adapter extends EventEmitter. Register listeners before calling run().

| Event | Payload | Description | |-------|---------|-------------| | 'event' | Event | Emitted for each new, validated event | | 'progress' | Progress | Emitted periodically with per-relay counters | | 'error' | Error | Emitted when a relay fetch fails |

Progress

interface Progress {
  relay: string
  found: number
  rejected: number
  total: number
  last_timestamp: number
  highest_timestamp: number
  lowest_timestamp: number
}

PQueueAdapterOptions

Extends TrawlerOptions with PQueue-specific settings:

| Option | Type | Default | Description | |--------|------|---------|-------------| | concurrency | number | 1 | Maximum concurrent jobs | | timeout | number | undefined | Per-job timeout in ms; undefined disables timeout | | intervalCap | number | — | Maximum jobs per interval | | interval | number | 0 | Rate-limiting interval in ms |

Known Limitations

No known limitations at this time.

Agent Skills

No agent skills defined yet for this package.

Related Packages

  • @nostrwatch/route66 — persistent relay state management; the primary consumer of crawled events
  • apps/trawler — reference application that uses nostrawl for continuous relay crawling

License

MIT