-
@ ever4st
2025-02-13 20:42:08Installation:
bash python3 -venv nostr-sdk source nostr-sdk/bin/activate pip install nostr_sdk requests
Python program: ``` pythonUsage example: python ns_read_metadata.py nostr:npub1mwce4c8qa2zn9zw9f372syrc9dsnqmyy3jkcmpqkzaze0slj94dqu6nmwy
Compatible with version 0.39
ns_read_metadata.py
version 3
import asyncio, argparse, json from nostr_sdk import Metadata, Client, NostrSigner, Keys, Filter, PublicKey, Kind from datetime import timedelta
async def main(npub): client = Client() await client.add_relay("wss://relay.damus.io") await client.connect() pk = PublicKey.parse(npub) print(f"\nGetting profile metadata for {npub}:") metadata = await client.fetch_metadata(pk, timedelta(seconds=15)) print(metadata)
if name == 'main': parser = argparse.ArgumentParser(description='Fetch all metadata for a given npub') parser.add_argument('npub', type=str, help='The npub of the user') args = parser.parse_args() asyncio.run(main(args.npub))
```