-
-
Save jiftechnify/f2d7ec15c09776b2f477e59efa997573 to your computer and use it in GitHub Desktop.
Nostrでのこれまでの投稿数を調べてみよう
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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