High level Nostr 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
import asyncio
from datetime import timedelta
from nostr_sdk import Keys, Client, NostrSigner, EventBuilder, Filter, Metadata, Nip46Signer, init_logger, LogLevel
import time
async def main():
# Init logger
init_logger(LogLevel.INFO)
# Initialize client without signer
# client = Client()
# Or, initialize with Keys signer
keys = Keys.generate()
signer = NostrSigner.keys(keys)
# Or, initialize with NIP46 signer
# app_keys = Keys.parse("..")
# uri = NostrConnectUri.parse("bunker://.. or nostrconnect://..")
# nip46 = await Nip46Signer.init(uri, app_keys, timedelta(seconds=60), None)
# signer = NostrSigner.nip46(nip46)
client = Client(signer)
# Add relays and connect
await client.add_relays(["wss://relay.damus.io", "wss://nos.lol"])
await client.connect()
# Send an event using the Nostr Signer
builder = EventBuilder.text_note("Test from Rust Nostr Python!", [])
await client.send_event_builder(builder)
await 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 = await 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...")
f = Filter().authors([keys.public_key(), custom_keys.public_key()])
events = await client.get_events_of([f], timedelta(seconds=10))
for event in events:
print(event.as_json())
asyncio.run(main())
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
Book
Learn more about rust-nostr
at https://rust-nostr.org.
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.13.0a2.dev0-cp312-cp312-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 35247b5c4521add2a0ac5ecb623db23fb3c848980b97d8f6a51aa306451df98f |
|
MD5 | 526f1ae0a142d52d76db2fd00d32e638 |
|
BLAKE2b-256 | 7073537f238d0b1ea1da6df79e26ccf9bc956634cc3ef6a343bf9f5ae63719f7 |
Hashes for nostr_sdk-0.13.0a2.dev0-cp312-cp312-manylinux_2_31_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ba887b4439bba2c6079ae1a1c063c4a2cc7cd11aecc2fb54a06e0792784d4411 |
|
MD5 | b28ed06635f667ebe293ab036bde4668 |
|
BLAKE2b-256 | a18519463610850174d7564f21aa01a42913b88840c2ad234a6d572b3edeb2cc |
Hashes for nostr_sdk-0.13.0a2.dev0-cp312-cp312-manylinux_2_31_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 55a9af731bab37b5e17183d96ca058ecd232a2a7da7d7cef936f5270756bbac6 |
|
MD5 | 2e2815ead9750d7068f4cb464b74401e |
|
BLAKE2b-256 | b3e1e54ba6e4e10f1d25cdbf067ddc182f60b3a14b960601a9064a652fb502ac |
Hashes for nostr_sdk-0.13.0a2.dev0-cp312-cp312-macosx_11_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 66e014edbc5c932038936f04c3cdac5dc652bb678a186e07fa263f91f2ffe31e |
|
MD5 | 81fc56486e6cbfe5e2f9e8c0fcd1016c |
|
BLAKE2b-256 | 8472a2cedfcec12e9d9f7b087ffaa42243b6f914c6657ed2be8f51e25e3ab106 |
Hashes for nostr_sdk-0.13.0a2.dev0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d08b77db39008ba035cf1aa00dc473c4a2e0acee3caaf14949a31e8b3acebedf |
|
MD5 | 06464a4e8cf4ba502375a9a08b14a4b3 |
|
BLAKE2b-256 | 83ea35881b76f311e6085401c8c83e653719e969500ebbe1e36ada3fb4c6bd03 |
Hashes for nostr_sdk-0.13.0a2.dev0-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | dcb93a3f5ffca316a70e4cfa5c838ccd491be520b3d17b4aa9ab71757ce1d6f5 |
|
MD5 | 8f9a62349ab26dd013af1c5d2b10c0b4 |
|
BLAKE2b-256 | 7638a4055d1080841acf9579346eb60bbb78c1948c8af8d63d0dfbc3f46516b3 |
Hashes for nostr_sdk-0.13.0a2.dev0-cp311-cp311-manylinux_2_31_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 18b64b5c009de73751dc98d056d2ebfb28e16ec4418f75b7f99400c3985038fa |
|
MD5 | 2763e2a60cd25cde373c3b591180eae7 |
|
BLAKE2b-256 | be8883e374db7df8373c18f128b381b06d5e1fbb2033147092f03848fe66cb85 |
Hashes for nostr_sdk-0.13.0a2.dev0-cp311-cp311-manylinux_2_31_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d8a232edd898f8cc25611c3f2a8aebe2a21b37c5b20c30db93b072e96f933dc2 |
|
MD5 | 6573ef80a39f1569a4440b1a8d20974d |
|
BLAKE2b-256 | 99696e4cf769a28515b4206e0bf56a25e0e4be99dad21f4d5cdf075e349c7ac1 |
Hashes for nostr_sdk-0.13.0a2.dev0-cp311-cp311-macosx_11_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2527c2621f3a5b19cb7d14b49aa26f54d7e06474d10059b8c2aeee26878aa593 |
|
MD5 | 1065c103d1eb364079d2d44f10d22634 |
|
BLAKE2b-256 | d0ffeaa42e4467e55b410047c647ebf4d4546a97bf3977004f46b68ba1149d3b |
Hashes for nostr_sdk-0.13.0a2.dev0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f93a6dab3f9619471b2d77e86002e3e5fff7bc2fe458317f750171a7bc72ea22 |
|
MD5 | e8dbded2c4fcecb0415751c759d6c79c |
|
BLAKE2b-256 | 90e7772463f43ca3e1618775b2f1104d902948e617b44f888d0d178dc6181cc9 |
Hashes for nostr_sdk-0.13.0a2.dev0-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 131757772df99ee9e6b1d5eb39e8c69da6ccc8539475e878ac9bba4e17985387 |
|
MD5 | 6566cbc511dfda0267d52220539d8c5a |
|
BLAKE2b-256 | 09af4c08c372107862a800dcf1ad5245c48559818d0d1750a55a9955e529a3eb |
Hashes for nostr_sdk-0.13.0a2.dev0-cp310-cp310-manylinux_2_31_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f15d08101dbaafc2ee66056adce4f77b937cc3f7103d4b6ad9aff56047668ac6 |
|
MD5 | 0b3c7b60470fee8ecd38c58f6211d51d |
|
BLAKE2b-256 | 897bed414e94c5cd3859db6a52d9dd79005b69c6eb7ae034351bee917324cd3f |
Hashes for nostr_sdk-0.13.0a2.dev0-cp310-cp310-manylinux_2_31_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5f81af5ca59c138a67fd835a7cc117da4916d0e0bb6be1c716c2ab7519a76ebd |
|
MD5 | 06828da4ea408c88a1991fc6cd55730c |
|
BLAKE2b-256 | 7e14b3faf5b500c639cfeb48ea78bccb048e53641c102882737fd9c86f4354eb |
Hashes for nostr_sdk-0.13.0a2.dev0-cp310-cp310-macosx_11_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 40e3455e62e74bf8c95c62baad8df7a994e14d99fc528fabb16f5236a2ceb09a |
|
MD5 | a2ab26a230b64fe7a192ac75becdd1c6 |
|
BLAKE2b-256 | 9a88db8f8456ee82a2bf520a8c2bc3b2080ab07d2a381ce723312cf468ecde40 |
Hashes for nostr_sdk-0.13.0a2.dev0-cp310-cp310-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f20849fe3da182b25938bec7a23fcdafdd89da4e31f83d22db8ba1ee770a01b7 |
|
MD5 | 1904519cd1a80bfc884d378059aacba8 |
|
BLAKE2b-256 | cc9be8fb5b7042ed66019befb6f92f00139be165c9514dadbf32d043e37ef3fd |
Hashes for nostr_sdk-0.13.0a2.dev0-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f7f8c99c2f4078e2b43cfe1c93b70759a0a4fcd9e58a3c54aab7e81881850616 |
|
MD5 | 272f415008428b9e4ea355a94f979a23 |
|
BLAKE2b-256 | 4418f29dc08f112b0fba7d35b85db31e25034d16bba1aba602971496ab2ec7d2 |
Hashes for nostr_sdk-0.13.0a2.dev0-cp39-cp39-manylinux_2_31_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d48ed01582199a54b3f520ddfe7500410c875195ae9fb6af7e0c8bd10b443e94 |
|
MD5 | 39bc6f925d7b89db10dc762b8233a9be |
|
BLAKE2b-256 | b9190432d88e6a461e44e679922c2b9e9f9733b89d18a3167730653025c5ba26 |
Hashes for nostr_sdk-0.13.0a2.dev0-cp39-cp39-manylinux_2_31_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e83c7bf4abdbdabfff2cfe4a98f3a4724e3f75e632f7f9204ffcc5ee1b086162 |
|
MD5 | 169d975c63df1564f1bed6696567b58f |
|
BLAKE2b-256 | 86fedd55132b82d7b46d3a8de2fdd8f8cc299ff3bc7f5d46898bc7bc739e5fd2 |
Hashes for nostr_sdk-0.13.0a2.dev0-cp39-cp39-macosx_11_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d7b1b0ad75ebb16dc186159006b87f31a40350e3d10ab8c03fc231246ea1a1a0 |
|
MD5 | b40adf84f5f1e95d22bcdd23a0f5de2b |
|
BLAKE2b-256 | f09461e851c9e61fcd9dfcad1a82bd78b505ef666e39a44ee44b89b8e84897b6 |
Hashes for nostr_sdk-0.13.0a2.dev0-cp39-cp39-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a511249549cde9fec8495d8fb5ea7557a6ed3ea829193f45e6beca1d0715ebc1 |
|
MD5 | 034a41cc055af4c6474fd7840ced351a |
|
BLAKE2b-256 | e431fda2de631efaa98c7826f74fd544bec27926095a343a54260d81a41a6002 |