Skip to main content

Installation

Install the Synvya SDK and setup a python environment if you haven’t done so already.
This is optional, but recommended.
python -m venv synvya-env
source synvya-env/bin/activate
pip install synvya-sdk
cd ~
mkdir synvya

Write your first Nostr note

cd ~/synvya
touch quickstart.py
quickstart.py
from dotenv import load_dotenv
from synvya_sdk import NostrKeys, NostrClient, generate_keys


# load private key / create new set of Nostr keys
NSEC = getenv("AGENT_KEY")
if NSEC is None:
    keys = generate_keys(env_var="AGENT_KEY")
else:
    keys = NostrKeys.from_private_key(NSEC)

# Use default relay
RELAY = "wss://relay.damus.io"

# Create the NostrClient instance
# The instance will connect to the RELAY and download the
# profile associated with the private key
nostr_client = NostrClient(keys.get_private_key(), RELAY)
try:
    note_id = nostr_client.publish_note("Hello, world!")
    print(f"Note published successfully with ID: {note_id}")
    print(f"Check it out at: https://www.primal.net/p/{keys.get_public_key()}")
except RuntimeError:
    print("Sorry, I couldn't post your first Nostr note.")
Your note was published as a Nostr kind:0 event. This is a simple text note that is viewable by any Nostr client that supports kind:0 events.Click on the link produced by the script to view your note on a web based Nostr client.It will look like this:
Congratulations! You’ve just published your first Nostr note 🚀🚀🚀