High level client library.
Project description
Nostr SDK - Python Package
Description
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
Getting started
pip install nostr-sdk
from nostr_sdk import Keys, Client, ClientSigner, EventBuilder, Filter, Metadata, Nip46Signer, init_logger, LogLevel
from datetime import timedelta
import time
# Init logger
init_logger(LogLevel.INFO)
# Initialize client without signer
# client = Client(None)
# Or, initialize with Keys signer
keys = Keys.generate()
signer = ClientSigner.keys(keys)
client = Client(signer)
# Or, initialize with NIP46 signer
# app_keys = Keys.generate()
# nip46 = Nip46Signer("wss://relay.damus.io", app_keys, None)
#signer = ClientSigner.nip46(nip46)
# client = Client(signer)
# Add a single relay
client.add_relay("wss://relay.damus.io")
# Add multiple relays
client.add_relays(["wss://relay.damus.io", "wss://nos.lol"])
# Connect
client.connect()
# Send an event using the Client Signer
builder = EventBuilder.text_note("Test from Rust Nostr Python!", [])
client.send_event_builder(builder)
client.set_metadata(Metadata().set_name("Testing Rust Nostr"))
# Mine a POW event and sign it with custom keys
custom_keys = Keys.generate()
print("Mining a POW text note...")
event = EventBuilder.text_note("Hello from Rust Nostr Python bindings!", []).to_pow_event(custom_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)
# Get events from relays
print("Getting events from relays...")
filter = Filter().authors([keys.public_key(), custom_keys.public_key()])
events = client.get_events_of([filter], timedelta(seconds=10))
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
Supported NIPs
Look at https://github.com/rust-nostr/nostr/tree/master/crates/nostr#supported-nips
State
This library is in an ALPHA state, things that are implemented generally work but the API will change in breaking ways.
Donations
rust-nostr
is free and open-source. This means we do not earn any revenue by selling it. Instead, we rely on your financial support. If you actively use any of the rust-nostr
libs/software/services, then please donate.
License
This project is distributed under the MIT software license - see the LICENSE file for details
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
Hashes for nostr_sdk-0.8.0-cp312-cp312-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8ddbc135e18a800ec4dd38b6b3a11648573eb6294024db5c7ee1dd7be00e53a3 |
|
MD5 | cf4c5a32b7318c6d764646b43998534a |
|
BLAKE2b-256 | 1750f33d1ce88f08d2ff66adb170f61f67c4f37e60e0caf56e3e3b96f48ca59f |
Hashes for nostr_sdk-0.8.0-cp312-cp312-manylinux_2_31_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0b828c771af528405e946cd22385cef9365608509eb64923e2b2dd0b76339b86 |
|
MD5 | c7354b896620e224820af51cc9a32f95 |
|
BLAKE2b-256 | e6eb2ce7bb29a9a1cf8d478d9241be0b620f87b20ff87799c5160486015c53d8 |
Hashes for nostr_sdk-0.8.0-cp312-cp312-manylinux_2_17_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 97eb57c2479460256ae4a673665c4d2007af247b8d3edaa5d0aaf18527655a8f |
|
MD5 | d60f1d31c7dd176f016e2ec2bd30d48d |
|
BLAKE2b-256 | 102bf3d5666410804e7dc7847599673952af70176a152f39fe390d8bd9250aae |
Hashes for nostr_sdk-0.8.0-cp312-cp312-macosx_11_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d3365d916ae32beaa7666ad797990d7ec8ddcae61e52b1d63630b711109b662e |
|
MD5 | 17ee26ce2893f48192b26908f2bdb62d |
|
BLAKE2b-256 | 729b5223a1e288d17d1379ee28c3aa80d2af62ddf85f9cc94f577166874b232e |
Hashes for nostr_sdk-0.8.0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c2dd4b2877e355945cbae3eca618c6363cb3330dc32b4dff1c2261c6381746cb |
|
MD5 | f91cb74a7808a420c442c2a2d479adfe |
|
BLAKE2b-256 | eaa4fd71d5ba6210005ec833834afed728447487d131347bf95a7f83d7d11e54 |
Hashes for nostr_sdk-0.8.0-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f8ca0d65c4c97d5f6a5b8ece54ce1bc0b991a3bbf7267ff637373e0d49352c58 |
|
MD5 | a7a795cfb04fb7b7b19f8003baf80537 |
|
BLAKE2b-256 | 8b52b5c3932722d1e915e8cb1388e9884d48e638dd31cc20933e17368ca82828 |
Hashes for nostr_sdk-0.8.0-cp311-cp311-manylinux_2_31_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 55e349568f675189549db924056952c3d702f19c0046a4ef4bf976292741b1dc |
|
MD5 | a79f2a289e433e649a2e349b6771c917 |
|
BLAKE2b-256 | ad2604d735ce20dda88d490b4ee6672c304e1f113d937792444ed7eac54b4dc3 |
Hashes for nostr_sdk-0.8.0-cp311-cp311-manylinux_2_17_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c0516cb2dcd0dc6fb291cd0bd24ad744a4b3acf9ffefa709134188a8e66ed793 |
|
MD5 | b83082ec30afe9e30d7020e124edeadd |
|
BLAKE2b-256 | 47eb3648bcc27e743c2e987fc22c3e0d9bd44a421e4822624861418870e796e4 |
Hashes for nostr_sdk-0.8.0-cp311-cp311-macosx_11_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a3971a8bb91217bec800652b100d4c2fc9c710509ff1d371ecc9976b65b194ec |
|
MD5 | 850c24eabba25fba0d29d7ae70b141fd |
|
BLAKE2b-256 | 1cd6a8d55a4b4ff3318c652b697e6325a0633a5b08614a5a6c4ab695f14094c1 |
Hashes for nostr_sdk-0.8.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 166010f2a3f8679df7c819bb2d59617a9965351c4ee28acda5a3acec1bb6932c |
|
MD5 | a3008b4bc83ff8e9e22f0ed0defd8d54 |
|
BLAKE2b-256 | f3b283bfae09930c4e54f67e768e27bbae2377968b795651a99febaa5a55a6a2 |
Hashes for nostr_sdk-0.8.0-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9ccd994c01c3465713026c23bf429852412e7bd58eb0e97ea29239ea490b5063 |
|
MD5 | 2065001fa34bfd4ad80bced9ada63618 |
|
BLAKE2b-256 | 72cbaea443b933d515c8c75d6b8a08e54b0dfbda0676c1d7bd05504424f524d6 |
Hashes for nostr_sdk-0.8.0-cp310-cp310-manylinux_2_31_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4232a6132f3b2e0ab8d4909d617f43b96a4e7e8514b70326c55f74c23253d291 |
|
MD5 | ff55464ccf640e500d072b8f6d3afe2a |
|
BLAKE2b-256 | 3bc0d5b053519606d448fc8fe40563f5c4865385f1304b24fbc9771b258edb20 |
Hashes for nostr_sdk-0.8.0-cp310-cp310-manylinux_2_17_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | de2f9b5ddf3c562ba86d5819a18b57988bdabd8b961d264f3f45a65f26f7a2e5 |
|
MD5 | 5c6fd93cd11a2989d9b934c9ce269571 |
|
BLAKE2b-256 | 85aeea58477e92fbd64f727f7b328b9a01b988a864a08d5996d880d4111068e6 |
Hashes for nostr_sdk-0.8.0-cp310-cp310-macosx_11_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3e351a3215561a47314ab83d0e402bc04d850cb79851c5130d8247fd900aeb72 |
|
MD5 | 3fbc918a07c3ed14aeadb5327aa04ff3 |
|
BLAKE2b-256 | d6eb1e2116ea153e6fa246f30cc135e3010c3a2b5fdd31e1db6df935321a509f |
Hashes for nostr_sdk-0.8.0-cp310-cp310-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3e73bd048f635372f075cf80c1fc0cdabfce194547b33c5c421d982113a39902 |
|
MD5 | 42ad34b2f7e38fcf0e551daecda66bed |
|
BLAKE2b-256 | 4fa04a7b8c4d92a6475dc9df3cccce0f9500d6199c85ad626868ff95e48caa12 |
Hashes for nostr_sdk-0.8.0-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 256fcbea72498a415f1d2f2febb33d3f3bc771eb6ba17869138857d9deb2f33a |
|
MD5 | 0feb0be153a57898b4417c085f6ea23d |
|
BLAKE2b-256 | bce874c64a2507f17259d91a21f1560f106e0706b35a767ccb1980878703be59 |
Hashes for nostr_sdk-0.8.0-cp39-cp39-manylinux_2_31_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6ee0e0717d1ff9bfb6813f1977bdbc214c8d314dc1ffda999ffcba0f76ef1aa8 |
|
MD5 | f84d2d394a979d6da2a959a79f6c2903 |
|
BLAKE2b-256 | c88ee6ef80d3b3f6639d177058f56876533d89cd56bb3f95bebc3f911691e0da |
Hashes for nostr_sdk-0.8.0-cp39-cp39-manylinux_2_17_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7cc536ec1bd10b6321e326264ec14db913c15dfca8456f312e6acbf5517cd5b7 |
|
MD5 | 756f8e9eeb3c8a19c4f48ac0cad98900 |
|
BLAKE2b-256 | 39664d26e7f4fabe12e13dced4e81c92addd53abc31ea6184162a4303addd4ca |
Hashes for nostr_sdk-0.8.0-cp39-cp39-macosx_11_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 353a572b3e43cfff52f7a41646a602d63bcdf2bfb02323c1f172a597d87ce9c1 |
|
MD5 | d3a83989f79712dd1dc8c9805f4a26a7 |
|
BLAKE2b-256 | b0d02eb08e260b15f97e615e85d991f6b6a4cc6294f3b7aab958d038cda843a6 |
Hashes for nostr_sdk-0.8.0-cp39-cp39-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 305c26394a269f345667fbf1671556d97dedebd9417d83bed5e0794fad5db8ab |
|
MD5 | c433cd018dde364fa19e6ad3dd6888fb |
|
BLAKE2b-256 | f1b6af1915769d8e2643fcd21a5804c0d748c473cf20c85989e0452d7a5257bb |