A high-level, Nostr client library.
If you're writing a typical Nostr client or bot, this is likely the crate you need.
However, the crate is designed in a modular way and depends on several other lower-level libraries. If you're attempting something more custom, you might be interested in these:
nostr-protocol: Implementation of Nostr protocol
pip install nostr-sdkfrom nostr_sdk import Keys, Client, EventBuilder, Filter
import time
keys = Keys.generate()
print(keys.public_key().to_bech32())
client = Client(keys)
client.add_relay("wss://relay.damus.io")
client.connect()
print("Mining a POW text note...")
event = EventBuilder.new_text_note("Hello from Rust Nostr Python bindings!", []).to_pow_event(keys, 20)
event_id = client.send_event(event)
print("Event sent:")
print(f" hex: {event_id.to_hex()}")
print(f" bech32: {event_id.to_bech32()}")
time.sleep(2.0)
print("Getting events from relays...")
filter = Filter().authors([keys.public_key().to_hex()])
events = client.get_events_of([filter], None)
for event in events:
print(event.as_json())More examples can be found at:
- https://github.com/rust-nostr/nostr/tree/master/bindings/nostr-ffi/bindings-python/examples
- https://github.com/rust-nostr/nostr/tree/master/bindings/nostr-sdk-ffi/bindings-python/examples
Look at https://github.com/rust-nostr/nostr/tree/master/crates/nostr#supported-nips
This library is in an ALPHA state, things that are implemented generally work but the API will change in breaking ways.
This project is distributed under the MIT software license - see the LICENSE file for details
⚡ Tips: https://getalby.com/p/yuki
⚡ Lightning Address: [email protected]