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, NostrSigner, 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 = NostrSigner.keys(keys)
client = Client(signer)
# Or, initialize with NIP46 signer
# app_keys = Keys.generate()
# nip46 = Nip46Signer("wss://relay.damus.io", app_keys, None)
#signer = NostrSigner.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 Nostr 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.9.0-cp312-cp312-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f8738110bb8d8600857c13da1372aa4555e0a6b3f03e2eee4e1f68db7d02cba5 |
|
MD5 | 11889d86c250ce77e136075a7fb41c84 |
|
BLAKE2b-256 | 5c02aee7b69b12bff249c68d33fbdfdd6de35ea5a36b7f62182c2b645a06bdec |
Hashes for nostr_sdk-0.9.0-cp312-cp312-manylinux_2_31_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b1f3cc179a49d83f4eca143b52a2555798d356e5c50897be879f21f4c52a3cef |
|
MD5 | 3df189cd1580d051ce59b842b8b6e370 |
|
BLAKE2b-256 | 5ba5ed25ac92c58f4810585f38903d5205dedff8df9a7506b8bd4438f2c25587 |
Hashes for nostr_sdk-0.9.0-cp312-cp312-manylinux_2_17_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3fd65f044a3a91a0c29cf49f576c1d8ee797e07de7c27cce6e1878a809e2a033 |
|
MD5 | da4ea11cf9bebf502cab7437f2bd1495 |
|
BLAKE2b-256 | 7cb8c5c89ff930778ddb8f70941345245b90035320667879ecf309282d008518 |
Hashes for nostr_sdk-0.9.0-cp312-cp312-macosx_11_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ab291181a7d3bd657fa39b8ba68dd33e99c20f0f4ec6649c847deff10a17baf8 |
|
MD5 | 537853a8b071be99d72b36eefb9e4da0 |
|
BLAKE2b-256 | c18bd78b8a7f73929885607b8cf2991b8a889dd22f40fc613926db8e2d70d180 |
Hashes for nostr_sdk-0.9.0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1509f3c85b1c384e83f0616ea19b81166b8ed1d665709a6a7478211eab1ef99f |
|
MD5 | ec28cf4bbe757735465d054e203be932 |
|
BLAKE2b-256 | 5cccc7423aa1f554f196c6f367000ec1b3528f249abe08a82fdbf5c668557731 |
Hashes for nostr_sdk-0.9.0-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b1b125bf102c40f94ba7048fc0c805760497b126179bb4340191a5cdb5a3eb79 |
|
MD5 | b9d637e80ec87380edf41fb5d3a19db8 |
|
BLAKE2b-256 | 4304c5d27bf0e380aade0f02602e1229f5ef438b69ac7faaf574ff0231019550 |
Hashes for nostr_sdk-0.9.0-cp311-cp311-manylinux_2_31_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7df54397e1e11e80ea8c8ae10b2de4041d5bb2fad45eae15beb05fbf9da6d382 |
|
MD5 | 5767ff51e0210975d20a84785c289b98 |
|
BLAKE2b-256 | d548f1c730c2a29440117263956e72201a1119d79ba5801941c776aba3989d0e |
Hashes for nostr_sdk-0.9.0-cp311-cp311-manylinux_2_17_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ae996f2ff153aa315564cedccbe7f5486cac2f79dfe93b5a8ea665eccea929a2 |
|
MD5 | b5a285dbdbae6cd4062cb5771a0b9952 |
|
BLAKE2b-256 | 871a956a7664fc9a7029ce2668e7c70e7760dd6c4ebe16e6ad9234cab3d0ad8c |
Hashes for nostr_sdk-0.9.0-cp311-cp311-macosx_11_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c0f584faf88a14e0bce572ebfc8fc97f2dfbcacf1713d01331b33ef7756898f6 |
|
MD5 | 06a9b8f2b4d024df14409f90c90c5c13 |
|
BLAKE2b-256 | 1948e8488ffc0ca22c3f6a1f99fba4f6f8c934b22c0032f788d73bfb9d211d1a |
Hashes for nostr_sdk-0.9.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 79c65889526d1a2df9a0a23666f7de8b398355855e3b5bfd68a6254ee966ac13 |
|
MD5 | 9e35b24f0729ae172917c949e9075eed |
|
BLAKE2b-256 | fc32652d0a7ae861bbd034e46d7675c8d7b1f3425947da546c6cb4d6dfcb7e7e |
Hashes for nostr_sdk-0.9.0-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ab15f433d28e1528d0d583fecf36239a6c2ddb3d2de43922c0a72ebf8918d86e |
|
MD5 | 8c92372adbff433681322068ed62158b |
|
BLAKE2b-256 | 2f8830a3bb6757c6f2df721e628d2c94e5b88010c877807264eb8b96792cd542 |
Hashes for nostr_sdk-0.9.0-cp310-cp310-manylinux_2_31_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 110a4c52a76ff5959dd1ecf4a77409d6f9782080ed2c99bbc110c12897a9b0cf |
|
MD5 | e4e9ca77601a93827bd4ca245be9fece |
|
BLAKE2b-256 | 33b20427619c31937144cb084d9a3157402a71de8834b3d41b3c5f357f83c442 |
Hashes for nostr_sdk-0.9.0-cp310-cp310-manylinux_2_17_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c3213275e964ba1b6f5244f02715f2860b749e228487247655c186c405c3abf2 |
|
MD5 | 843f9d922279ebb1c7cc8f464215e3dc |
|
BLAKE2b-256 | d7ee15ff30c9a71da0856b982323bab0256f0c78689d5aa92dfe0b4918f8819e |
Hashes for nostr_sdk-0.9.0-cp310-cp310-macosx_11_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1ea8bb48f47b3b97c8661876c302d04c33461b682e42aa0a85bd2c3ebc92d09a |
|
MD5 | b9b0803b2dcf6273dabdf46455e6b6d4 |
|
BLAKE2b-256 | fe09fe5e04d5f231be8daddf355b76842b595a86242766e54dc481f7569bc1c8 |
Hashes for nostr_sdk-0.9.0-cp310-cp310-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 69529fcf3bc5797d0094ea9e22f91632b5165f9a4597b53a086a5ad9b2f516e3 |
|
MD5 | cd1bc94de6e47062de8cda552dab4baf |
|
BLAKE2b-256 | 4f3a06b85e9dd6f20f58e36dc6862601153e98c3959ed3d2077256e8355e4133 |
Hashes for nostr_sdk-0.9.0-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1cd5d993c2f379a63da0285dcd326fb97c09dec2de19b20b72cd2980bb8bfa69 |
|
MD5 | d686b9048f5d63ebdc328298cf9db87d |
|
BLAKE2b-256 | 1820a0def81023c65190602c26ff8800446cffd0df738dbdb90b104e55747a96 |
Hashes for nostr_sdk-0.9.0-cp39-cp39-manylinux_2_31_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3f274bd43ca356899d9f3b8af85dc497ca798c9982a1b56cd5fcdd2c4659fb76 |
|
MD5 | 4af06fa7ca168f8a1e3502d8702c7e70 |
|
BLAKE2b-256 | a055b29b5fe0d886f8e3c97f666564aaa97162277d890b412cc085f3bb3e9dfa |
Hashes for nostr_sdk-0.9.0-cp39-cp39-manylinux_2_17_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 65c496e0c8c81fc27c6af45053e2977f7c0f9566b4da018978c2c440a443cefc |
|
MD5 | 8de061085cf80c95eb2a9e7de548d36d |
|
BLAKE2b-256 | 0d70defd092cc2a32a196fde6806b05e64c19ecc13bb4187b077cfe6a865af70 |
Hashes for nostr_sdk-0.9.0-cp39-cp39-macosx_11_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ffaed0ba8c6f99e0465ea1a23a2585ec4610446f8bcf9f85cc8ef604c9cb4e78 |
|
MD5 | c5599bcce76f2250f61bc2782a523ee7 |
|
BLAKE2b-256 | 76d8427dfbc1037fc8f346cfb5de564e5461c12a4bfbace72306b71f3bc4fef3 |
Hashes for nostr_sdk-0.9.0-cp39-cp39-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2ba1b80de69269bdaff40a1aea41338aff4c7db52d3dcc8644052a68e1535ad5 |
|
MD5 | dab118bb860b827c6992fad987fe7612 |
|
BLAKE2b-256 | 4508d651d7ec42743c618eed481d92af4734c579579a43c64562d0e599fcfb7d |