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

@relay-federation/sdk

v0.2.0

Published

JavaScript SDK for the Federated SPV Relay Mesh — connect to any bridge from your app

Readme

@relay-federation/sdk

JavaScript SDK for the Federated SPV Relay Mesh. Connect to any bridge from your app.

Install

npm install @relay-federation/sdk

Quick Start

import { RelayBridge } from '@relay-federation/sdk'

const bridge = new RelayBridge('http://your-bridge:9333')

// Get bridge status
const status = await bridge.getStatus()
console.log(`Height: ${status.headers.bestHeight}, Peers: ${status.peers.connected}`)

// Fetch a transaction
const tx = await bridge.getTx('abc123...')
console.log(`Source: ${tx.source}, Outputs: ${tx.outputs.length}`)

// Broadcast a raw transaction
const result = await bridge.broadcast('0100000001...')
console.log(`Relayed to ${result.peers} peers`)

// Query inscriptions
const images = await bridge.getInscriptions({ mime: 'image/png', limit: 10 })
console.log(`Found ${images.count} of ${images.total} total`)

// Get address history
const history = await bridge.getAddressHistory('1Abc...')

// Discover other bridges on the mesh
const mesh = await bridge.discover()
console.log(`${mesh.count} bridges on the network`)

API

Constructor

const bridge = new RelayBridge(baseUrl, options?)

| Option | Type | Default | Description | |---|---|---|---| | auth | string | — | Operator statusSecret for authenticated endpoints | | timeout | number | 10000 | Request timeout in milliseconds |

Public Methods

| Method | Returns | Description | |---|---|---| | getStatus() | status object | Bridge status (peers, headers, mempool, BSV node) | | getMempool() | { count, txs } | Parsed mempool transactions | | getTx(txid) | tx object | Fetch and parse a transaction | | broadcast(rawHex) | { txid, peers } | Relay a raw transaction to mesh peers | | getInscriptions(filters?) | { total, count, inscriptions } | Query indexed inscriptions | | getInscriptionContent(txid, vout) | { data, contentType } | Raw inscription content | | getAddressHistory(address) | { address, history } | Transaction history for an address | | discover() | { count, bridges } | All bridges known to this node | | getApps() | { apps } | Health/SSL/usage for configured apps | | getSessions(address) | { address, sessions, count } | Session metadata for an address | | indexSession(session) | { ok } | Index a session (syncs to peers via SessionRelay) | | backfillSessions(sessions) | { ok, indexed } | Bulk-index sessions | | getRawTx(txid) | hex string | Raw transaction hex | | getUnspent(address) | array of UTXOs | Unspent outputs for an address |

Operator Methods (require auth)

| Method | Returns | Description | |---|---|---| | register() | { jobId, stream } | Start on-chain registration | | deregister(reason?) | { jobId, stream } | Start on-chain deregistration | | fund(rawHex) | { stored, balance } | Store a funding transaction | | connect(endpoint) | { endpoint, status } | Connect to a peer | | send(toAddress, amount) | { jobId, stream } | Send BSV from bridge wallet | | scanAddress(address, onProgress?) | { scanned, found, indexed } | Scan address for inscriptions | | rebuildInscriptionIndex() | { rebuilt } | Rebuild inscription indexes | | getJob(jobId) | events array | Get async job progress |

Inscription Filters

await bridge.getInscriptions({
  mime: 'image/png',       // filter by content type
  address: '1Abc...',      // filter by receiving address
  limit: 100               // max results (capped at 200)
})

Error Handling

import { RelayBridge, BridgeError } from '@relay-federation/sdk'

try {
  const tx = await bridge.getTx('bad-txid')
} catch (err) {
  if (err instanceof BridgeError) {
    console.log(err.status)  // HTTP status code (e.g. 404)
    console.log(err.message) // Error message from bridge
  }
}

Multi-Bridge Discovery

// Connect to one bridge, discover the rest
const entry = new RelayBridge('http://your-bridge:9333')
const mesh = await entry.discover()

// Connect to all bridges
const bridges = mesh.bridges.map(b => new RelayBridge(b.statusUrl))

// Query across the mesh
for (const bridge of bridges) {
  const status = await bridge.getStatus()
  console.log(`${status.bridge.pubkeyHex?.slice(0, 8)}... height=${status.headers.bestHeight}`)
}

Round-Robin Failover

For production apps, round-robin across multiple bridges so one failure doesn't take you down:

const bridges = [
  new RelayBridge('http://bridge-alpha:9333', { timeout: 8000 }),
  new RelayBridge('http://bridge-beta:9333', { timeout: 8000 }),
  new RelayBridge('http://bridge-gamma:9333', { timeout: 8000 }),
]

let idx = 0

async function meshCall(fn) {
  const startIdx = idx++ % bridges.length
  for (let i = 0; i < bridges.length; i++) {
    try {
      return await fn(bridges[(startIdx + i) % bridges.length])
    } catch (_) { /* try next */ }
  }
  throw new Error('All bridges failed')
}

// Usage
const tx = await meshCall(b => b.getTx('abc123...'))
const result = await meshCall(b => b.broadcast('0100...'))

Building Apps

Apps are consumers of the federation — they run anywhere and talk to bridges via this SDK or plain REST. See the full guide: Building Apps on the Federation

Requirements

  • Node.js >= 18 (uses native fetch)
  • Works in browsers with fetch support

License

MIT