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
from nostr_sdk import Keys, Client, NostrSigner, EventBuilder, Filter, Metadata, Nip46Signer, init_logger, LogLevel, \
NostrConnectUri
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)
# Or, initialize with NIP46 signer
# app_keys = Keys.parse("..")
# uri = NostrConnectUri.parse("bunker://.. or nostrconnect://..")
# nip46 = Nip46Signer(uri, app_keys, timedelta(seconds=60), None)
# signer = NostrSigner.nip46(nip46)
client = Client(signer)
# Add relays and connect
client.add_relays(["wss://relay.damus.io", "wss://nos.lol"])
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...")
f = Filter().authors([keys.public_key(), custom_keys.public_key()])
events = client.get_events_of([f], 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
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.12.0-cp312-cp312-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5eb8b0e0e62ef8f4eb954a956c38668b5ca9a029aef473607af1b335c4464e44 |
|
MD5 | 82b801430fd3e7afe75435d523db0541 |
|
BLAKE2b-256 | 88a43d9658c1423ad8cbdbdeb4c63b3ce51b19dd18b173b7120fbe7ce3add53e |
Hashes for nostr_sdk-0.12.0-cp312-cp312-manylinux_2_31_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0a4244315be1562c5827847d2dec7683b96053ef7e8d8be743d24ebb2a125950 |
|
MD5 | a154c70245bd66d6181da9b138b0c447 |
|
BLAKE2b-256 | 6005f2771dd41d59863583bf1c48568647f796580c7b74abf43b5632948799dd |
Hashes for nostr_sdk-0.12.0-cp312-cp312-manylinux_2_31_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0012c628924a2724cf349579b93d0d97a41189c0be2569f66b8aaba85c42868e |
|
MD5 | 22e70fce2ebc05694dbe22e5279fe8e8 |
|
BLAKE2b-256 | 02238fbab2bdfdc9816cfab127bbc1661207ee3f5670afc0324b71920959a60e |
Hashes for nostr_sdk-0.12.0-cp312-cp312-macosx_11_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 62eb418a1eb0ec8531fcbc007dd03616092cec18122589c7b1174a4c9f63ccb0 |
|
MD5 | c950c53622ac6a2b8d20bee35ff041ba |
|
BLAKE2b-256 | 50bd2545b53fef0d6d04bcd7dc48150ec18be3b81552299ec8e8bb494655adec |
Hashes for nostr_sdk-0.12.0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4dc5f71efb860091765549f7935e468673d0c0c516c87604e7f540374517182b |
|
MD5 | c34946bdc83803514c097d5656bb4408 |
|
BLAKE2b-256 | a2aeb68a11b6d395d1eefc6df209c9c4c1e3b4d3ca81288fee688ff57723fba0 |
Hashes for nostr_sdk-0.12.0-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5f6ef004defbfe826b7b70de3948929bb49c19b17db1758b04cce0d5701ad7f7 |
|
MD5 | c6e7a3df232cf45a98e0a145c2b7f6fe |
|
BLAKE2b-256 | 6bb5db50e72b027e31bff765cb32f11452698e0c411e827e8b6092e6bef422eb |
Hashes for nostr_sdk-0.12.0-cp311-cp311-manylinux_2_31_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4e81b86470997d223cd3d41ff88e7ae996a5d63894dd3eb86078eeb19a1e20fc |
|
MD5 | 604cf0644ae6a8cfb3a398ffb34749a5 |
|
BLAKE2b-256 | 5b59a3d3906d763a12ceafa371d6b4bdb78073c8d6f99d279369ed30d5604392 |
Hashes for nostr_sdk-0.12.0-cp311-cp311-manylinux_2_31_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b0b7d0ff7bef44efa909efe40f82343c04e54a48aa3a201e7228d02a5e084b02 |
|
MD5 | 7c31a9e80d57e128a45ac257df769205 |
|
BLAKE2b-256 | cdf10c948b401684602c0bb1b45b65855319904353fe11337ea39c437fe172c0 |
Hashes for nostr_sdk-0.12.0-cp311-cp311-macosx_11_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6e22407188d983011d4c06270670ab522468c85c9265695059c5968ffb541646 |
|
MD5 | 5c32e2bd079e789041f51ed11b422263 |
|
BLAKE2b-256 | e23e22baa5eb4164db47f301690061b543a64a11245b4787cfd8c520f79595fc |
Hashes for nostr_sdk-0.12.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 035599a344c7ac191cd67e3e6132dbc99ee54b6f5c02ab476b6ab9b4a26babf9 |
|
MD5 | a64d1b6d828a5ebf487fe34adca8b00d |
|
BLAKE2b-256 | ff89a37a601f1140654fbc0d8fef184442487ebc111cad5bb7edda03c3868395 |
Hashes for nostr_sdk-0.12.0-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e5bca3a97aa4b9da25a8724b83cf8a1dc1af6e60cd784531eb88e63176d0f249 |
|
MD5 | 9497bb8b03ba52b2876f9dd575f9bfc0 |
|
BLAKE2b-256 | 3e0203b781f783f8e63b02c835f172be635e20e3a0cd1bdb47716a6d96170cb7 |
Hashes for nostr_sdk-0.12.0-cp310-cp310-manylinux_2_31_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0f340503528edb6d2875a38e10f9b8e0f4731069258a92237f22248ec07687eb |
|
MD5 | a0395de031042fb1485f3a4d2bc40236 |
|
BLAKE2b-256 | 65224b3ae6eb87f1cd5cc80c762671452b7c2344d458ecae07fafaa2b394554f |
Hashes for nostr_sdk-0.12.0-cp310-cp310-manylinux_2_31_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e5e0e123c2cbb9b05a20d5b0a0c3ce3f8ad50c66bcd194cdf05191ea0b8b678b |
|
MD5 | 604b0cb2267e27ce58615fbb9ebf2e12 |
|
BLAKE2b-256 | 4f7aff93da37ef832cdb0a104eaa78233db84a9e0b718046b102ffee0f7f73e8 |
Hashes for nostr_sdk-0.12.0-cp310-cp310-macosx_11_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 491008cbb1eb176cda567065380f970e7c7788504ad3e1059e92a897a0cd08ce |
|
MD5 | 2466c19839ab955a4ee264ce003cbc40 |
|
BLAKE2b-256 | bfe5d1e27431f20c8ed6e33552e656ae2ccaa693b7c88ade578221e1e9eb559c |
Hashes for nostr_sdk-0.12.0-cp310-cp310-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a47adcdd873e7c18ccd596b6da6477c09c8dec2ac4b00bad171cd9545aa99eab |
|
MD5 | 6e275c36ce2762d4e941fe541d08e6e4 |
|
BLAKE2b-256 | 2ad267781cc750348f368dd02bf541369f49d0541715550355fdd1edeed1713b |
Hashes for nostr_sdk-0.12.0-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 211dd3ceb02b4880e56a16f1fee31108952a4c7c3a7b07ef96feec678684e0c4 |
|
MD5 | 3ecba3ea8fd70e7dae2bfd8eb200e13d |
|
BLAKE2b-256 | 8b9da32b063ce4637afa8dcff8f44077b5e61b7988a305c7b92f2ccfb78c728d |
Hashes for nostr_sdk-0.12.0-cp39-cp39-manylinux_2_31_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1e6f8fe086c7a154c760b936a73f183649d8bc5722e7b5db779bd86c7b4f9ea8 |
|
MD5 | 8c77f68fb570a2538db41e6d20722398 |
|
BLAKE2b-256 | 6325b1000f20204163193c4c0fd5eca7db8a343a5eeb142c4e4cb39bec6ccd13 |
Hashes for nostr_sdk-0.12.0-cp39-cp39-manylinux_2_31_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5b542885f2485036e74db7cf4a2a90294abf36614f9688afe0d1338d39bea279 |
|
MD5 | dac008adf12671560dbfd17e10029c08 |
|
BLAKE2b-256 | f706c772e6e8509b50abc7d37091fcf85ee2a2e848c4817a3fdb59d8e3fdd370 |
Hashes for nostr_sdk-0.12.0-cp39-cp39-macosx_11_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 25cc2cfba276089bb960137286ab1d30b8d65e9b0ee5450e101cd37c026befd4 |
|
MD5 | b4f9abf67d932650a5b666830115661c |
|
BLAKE2b-256 | b1dd4e8c03d0ca122c1e469d22b665d65766e2dee2a5b7390f81582aa1991d2f |
Hashes for nostr_sdk-0.12.0-cp39-cp39-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | aa5cc73078f4375a2a825d76b250a4c8c9477553fa64ad11a30027c42cd39d49 |
|
MD5 | 522f6fa8d7d80ae8a22cb4fa18b9ddc9 |
|
BLAKE2b-256 | 24079afa13508cb7ed5a584741113a3f52316c344f6c44acde325af70322d03c |