Nostr WoT

Documentation

Everything you need to integrate Web of Trust into your application.

Quick Start

Get up and running with Web of Trust in just a few minutes.

Browser (with Extension)

For client-side applications, use the browser extension API. Users will need the WoT Extension installed.

1. Check for Extension

javascript
// Feature detection
function hasWoT() {
  return typeof window !== "undefined" &&
         window.nostr?.wot !== undefined;
}

// Wait for extension to load
async function waitForWoT(timeout = 3000) {
  const start = Date.now();
  while (!hasWoT() && Date.now() - start < timeout) {
    await new Promise(r => setTimeout(r, 100));
  }
  return hasWoT();
}

2. Query Trust Distance

javascript
// Get distance to a pubkey
const distance = await window.nostr.wot.getDistance(
  "npub1targetpubkey..."
);

if (distance !== null && distance <= 2) {
  // Within web of trust
  console.log(`Trusted: ${distance} hops away`);
} else {
  // Outside web of trust or not connected
  console.log("Not in your web of trust");
}

Tip: Distance values: 0 = yourself, 1 = direct follow, 2 = follow of follow, null = not connected.

Server (with Oracle API)

For server-side applications, use the Oracle REST API. No extension required.

Using fetch

javascript
const response = await fetch(
  `https://wot-oracle.dtonon.com/distance?` +
  `from=${fromPubkey}&to=${toPubkey}`
);
const data = await response.json();

console.log(`Distance: ${data.distance}`);
console.log(`Paths: ${data.paths}`);
console.log(`Mutual follow: ${data.mutual}`);

Using cURL

terminal
$curl "https://wot-oracle.dtonon.com/distance?from=82341f...&to=3bf0c6..."

Using the SDK

For TypeScript projects, install our SDK for type-safe Oracle API access:

terminal
$npm install @anthropic/wot-sdk
typescript
import { WoTClient } from "@anthropic/wot-sdk";

const client = new WoTClient({
  baseUrl: "https://wot-oracle.dtonon.com",
});

const result = await client.getDistance(fromPubkey, toPubkey);
console.log(result.distance);

Next Steps