How to pullout nostr:profile in python? Thanks

#asknostr

Reply to this note

Please Login to reply.

Discussion

What do you mean by pull it out?

From nsec to nprofile

Send a request for kind 0 to your relay, and put the hex formatted npub in the author tag

`["REQ","some id code",{"kinds":[0],"authors":["800e0fe3d8638ce3f75a56ed865df9d96fc9d9cd2f75550df0d7f5c1d8468b0b"]}]`

Read it...

What i need is something to decode like this

NOSTR_PRIVATE_KEY.public_key.bech32() <- this is to npub

```python

from nostr_protocol import Keys, Nip19Profile

# OR `from nostr_sdk import Keys, Nip19Profile`

keys = Keys.parse("") # nsec or hex

public_key = keys.public_key()

profile = Nip19Profile(public_key, relays=["wss://relay.damus.io"])

print(f"NIP-19: {profile.to_bech32()}")

print(f"NIP-21: {profile.to_nostr_uri()}")

```

You can learn more here (NIP-19 and NIP-21 sections): https://rust-nostr.org/

rust-nostr python bindings

https://pypi.org/project/nostr-protocol/

Ok, decoded nprofile but as I can see nprofile sent from amethyst is not same as nprofile decoded. How is that?