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.1-cp312-cp312-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9f2c5a6db352e54bebc871ba20c17681ebce919afcb069cf8278836400478de9 |
|
MD5 | df0494903ba650c08d6ccabd23982e1d |
|
BLAKE2b-256 | f63afbbb72385055f4cce20d878271b79b4908bde491b23bb5ad55c846945eec |
Hashes for nostr_sdk-0.9.1-cp312-cp312-manylinux_2_31_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5d48497b3bfe64836f8e82e297d595c525cb963bcf77812b088b882c90453e14 |
|
MD5 | 258b3ebc2761af37daf2d71eae0ed705 |
|
BLAKE2b-256 | 1803c70bf813e55511df31c7743c6ba928b8957e843261f2cd243b91b80cafe9 |
Hashes for nostr_sdk-0.9.1-cp312-cp312-manylinux_2_17_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 358e05c730eeeabb4f29ee5202356d089851766b1df47d0a36c8d8f8f7879443 |
|
MD5 | 4a4ea746868f615d240b67e9930a0904 |
|
BLAKE2b-256 | 965b83aabf6da8ac0b24b1599697ca826dc2f6eac84b14aad1e3ea3b0c7d1d57 |
Hashes for nostr_sdk-0.9.1-cp312-cp312-macosx_11_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d655d429525e1c8c62d252579803dd8ad81e3fe8eda7ae3dc573438358c5ca78 |
|
MD5 | 9594595ae6763d3d71465df20929f508 |
|
BLAKE2b-256 | d1908ec14b3edc02ff89d6da807a455ecd1ea175e4d2804481f42dbf384fa5b0 |
Hashes for nostr_sdk-0.9.1-cp312-cp312-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 91cd10d1e8f6fc6c3c7192260f45ecd11a7746ddd2005746161038f3d3958ec9 |
|
MD5 | 5846b403adfd1ee35c4d0eefaf7cb0fc |
|
BLAKE2b-256 | 90e56d573f7ba7e074f40b27c3d2e4441505a4d28780c5603c4b8f99c03e9431 |
Hashes for nostr_sdk-0.9.1-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6c7aa2b76e5bbe746b8562569e299d247458f42e0fa3a40bf22b2d59f4012b84 |
|
MD5 | c272eff7499a19a62560541ff0b0c116 |
|
BLAKE2b-256 | 8744d8462e000c25dedf795a774857b271ee9ae5a41b02114322d0f48d46eb82 |
Hashes for nostr_sdk-0.9.1-cp311-cp311-manylinux_2_31_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 11bfc4bf05fb095c081d4469ed5c5bf0b4397b8ffe42a5d867998170941020eb |
|
MD5 | e15194474d0c4bcc9e7879b83cc65446 |
|
BLAKE2b-256 | 3c8be2bf830cae156ebb32944b076db3d19585bfa89ad336f2819c5e70958575 |
Hashes for nostr_sdk-0.9.1-cp311-cp311-manylinux_2_17_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5289afc0785e4288a5db4295940c3c4c27cc008bde63a41e513104606942c738 |
|
MD5 | 2d2b5aff092996870b5af43047ce0a9b |
|
BLAKE2b-256 | dd4f33b82106d2a29b44fb771083356c3679197ef696599b04d50df46ed6455c |
Hashes for nostr_sdk-0.9.1-cp311-cp311-macosx_11_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fa8121a3f0095abf4c20ba043bce9a1d41517601c3d9ea6317fcc719e0ebf96c |
|
MD5 | 5f5207c63e43c1b4e8d999849af1db5b |
|
BLAKE2b-256 | f30612600094c50022dce886b2888993d214f4ed026071eb85f465add11973fa |
Hashes for nostr_sdk-0.9.1-cp311-cp311-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6051d84aa9e2dfee5b251815b70e7e7d5458c5a28c2a8a1101e19bb68e1ac6e3 |
|
MD5 | cb4c356a0afce24350122b6bb3449e75 |
|
BLAKE2b-256 | 8de290a03b3e1bd72c2faaaa1c3f7726f7044bfda550eca0f5bc2fff3dfb4ab2 |
Hashes for nostr_sdk-0.9.1-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8658573ba984e53ac621138304605d8c24840cbebf1d707907e147ee352716cd |
|
MD5 | 589df9fb5375a505a5c735f75f32cd14 |
|
BLAKE2b-256 | 1186e3e5d8d866aa786041be169e2546d4411908e3dbc70bc08bcf3f686d98eb |
Hashes for nostr_sdk-0.9.1-cp310-cp310-manylinux_2_31_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0bfdb80db3b73d3a4a0f98ef95f8f630d27e754b5e6cfe773b00e9a379dc6222 |
|
MD5 | c86d1f33eab483ed49b83e941ec87f52 |
|
BLAKE2b-256 | 19661d9b6a9097a59ff6cf101d2beb4b9d4fa1b221a42752004776ca6b65fb7e |
Hashes for nostr_sdk-0.9.1-cp310-cp310-manylinux_2_17_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 726af7e8e1dc61d7c86b4c7ce27e2cbae99da8a92d4a91d8c3b371482353fea0 |
|
MD5 | e6cf8978b175a4ec3f3f8408fa5694c9 |
|
BLAKE2b-256 | e4d0ce055746bfe6250a30b6e529bde15c304f9435804b9e0a50f45e76a2fce9 |
Hashes for nostr_sdk-0.9.1-cp310-cp310-macosx_11_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e2c4626fe43abbfa35257a6c8ad245ff4e2ff4520cd2c0748f927e5824bba891 |
|
MD5 | cd6ecf33a8c0cdc1fc1181ccbce5bfd1 |
|
BLAKE2b-256 | 3c8aaa111143b010240092f96131756c77a43c11304ec7526994d8999e397fef |
Hashes for nostr_sdk-0.9.1-cp310-cp310-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e771f9f6b871af0be365ca2a33bce77a0f55f1037ca39bafdb53d89b52e39272 |
|
MD5 | 7bb5ec283f3b19b1996bb10f4d313cd5 |
|
BLAKE2b-256 | 22f709443893e946de1d1aa189656de803cd80114c1c4fa8c2753a42f0864e38 |
Hashes for nostr_sdk-0.9.1-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f3e723855af39f33a32e519730f00fde50fa138e6f9d716c247fc48e90efce1f |
|
MD5 | 7b41da805583d676ee5ad9dae9777177 |
|
BLAKE2b-256 | 3344d8f996143a17071a539eb75c0bfaffcb2336e40e14d238b4bc1eb2e47309 |
Hashes for nostr_sdk-0.9.1-cp39-cp39-manylinux_2_31_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 91bb1c3bcee44352896c106dab22ead5d674438ce5b0fb918b6f2ac2d3336bbb |
|
MD5 | fd67276acc694e827daaaf972521420e |
|
BLAKE2b-256 | 407e00b0af76586b7c64a88d10d9d9447ee34da49fdc4675e051b59a3f9bc26c |
Hashes for nostr_sdk-0.9.1-cp39-cp39-manylinux_2_17_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8fe83b72ef09e616781bd3873c6dd0c07def2db91fe9575db1d2f3c2dbdf0291 |
|
MD5 | a7c745d019298c672976a74d48500521 |
|
BLAKE2b-256 | b9aa1c79661fadf950c39460b1146c4978d7531c61c49cb109bc56ed126014fc |
Hashes for nostr_sdk-0.9.1-cp39-cp39-macosx_11_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9356433f287c57a6bc52097b379048fbaa83892f38eb96fd8af0ee4669d365e2 |
|
MD5 | 022d9dc122dd3f1f935cf8ae6f1462c2 |
|
BLAKE2b-256 | e4c8ca46f6bd4b268c728f1e8e82e55d15ae9c50aa1545bf8e5c49ad3e958ccb |
Hashes for nostr_sdk-0.9.1-cp39-cp39-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3bb00995812097f7b46d905a868a910ddda49c1c53cd8327123770277d204fcb |
|
MD5 | 2ce3781a64d3fa7b295585fa8ce62e88 |
|
BLAKE2b-256 | a903f5273d5908c0b3c3c27e7d96bcde645de838f62659bdfe74c72b99a9b4a1 |