Skip to content

Instantly share code, notes, and snippets.

@jiftechnify
Last active November 17, 2023 06:28
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jiftechnify/f2d7ec15c09776b2f477e59efa997573 to your computer and use it in GitHub Desktop.
Save jiftechnify/f2d7ec15c09776b2f477e59efa997573 to your computer and use it in GitHub Desktop.
Nostrでのこれまでの投稿数を調べてみよう
// 1. npm init
// 2. npm install nostr-fetch websocket-polyfill
// 3. node index.js
const { eventKind, NostrFetcher } = require("nostr-fetch");
require("websocket-polyfill");
// お好みで
const relays = [
"wss://relay-jp.nostr.wirednet.jp",
"wss://nostr.h3z.jp",
"wss://nostr.holybea.com",
];
const main = async () => {
const fetcher = new NostrFetcher();
const events = await fetcher.fetchAllEvents(
relays,
[
{
kinds: [eventKind.text], // リポストを含めるには、配列に 6 を追加
authors: ["<your hex pubkey>"],
},
],
{}, // since, untilを指定すれば特定期間の数を調べられる
{ skipVerification: true }, // 署名検証をスキップすると速くなります
);
console.log(`you've posted ${events.length} posts so far!`);
fetcher.shutdown();
};
main().catch((e) => {
console.error(e);
process.exit(1);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment