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.10.0-cp312-cp312-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6adfcbfd6e4722b8c322d58425300532be5ef101562a55319619673daad3e095 |
|
MD5 | 17962d94f426cc15de4b591c642b0613 |
|
BLAKE2b-256 | 92fc542c557eb9eac37ef2a6b5911d455621fefeb28164f159cc29833df81fee |
Hashes for nostr_sdk-0.10.0-cp312-cp312-manylinux_2_31_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e777fa99005e014025aab18ee501eb440e4c132f9978281c3d0d3ac17edcc579 |
|
MD5 | e973532baad33e87e470fe30b2f10567 |
|
BLAKE2b-256 | 7df9032095582d25980ba967269e5d9ef5b3e05d7b449b03d05846ad87093976 |
Hashes for nostr_sdk-0.10.0-cp312-cp312-manylinux_2_17_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a91af900ced001e9ce072e267b674e11cba518e31561dc32b78a1f9f667b4f0b |
|
MD5 | d4d4890e55c11b3587f2641048e0bc3e |
|
BLAKE2b-256 | 178b9b605eeea23be75b9738aeb14ad6db57888cfb7b64825034845fb2ab0311 |
Hashes for nostr_sdk-0.10.0-cp312-cp312-macosx_11_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e97617579edbd8696f7e507465fb1608b8cb77d6965c931220ed6a09a58e87ff |
|
MD5 | 237ddfd6d41dbb2cc6cfaa97c55743a9 |
|
BLAKE2b-256 | cbea0b34a32af66f432fbe66eaefa7f65d829bde6e37b10d2237b8b12cdf2970 |
Hashes for nostr_sdk-0.10.0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 437e3e44b5807249d9edc53544e66d737b87de86b0f82f8300467c07080389ab |
|
MD5 | 832f085ff84e0f3483d3e21581b9862d |
|
BLAKE2b-256 | b088014250dca94160dde3d00d3e13c0a8c17d945ed4aed362ab9fda6d2fb89f |
Hashes for nostr_sdk-0.10.0-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ee4c52152ae5bb2903e859db3ea43312f97f5efc9a4f7cc02ddb2b4423f7ea8a |
|
MD5 | 3a92cb86a43e44474856576a1b23d27e |
|
BLAKE2b-256 | 2eef2e5fa6bb58ca9d1676e3021f470d2c20c6161b6469cfc431e138fb827a8e |
Hashes for nostr_sdk-0.10.0-cp311-cp311-manylinux_2_31_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6a0c4280bbbeaafbb4c443f1fbd99cd9713c080f04cecf99b9da92b37201ccff |
|
MD5 | 45c3bb26e13585e8a25dfc73757b472b |
|
BLAKE2b-256 | 5d1aea98a99d2318523e4cec7944411aa965e7233404ded55f94ae2833af3923 |
Hashes for nostr_sdk-0.10.0-cp311-cp311-manylinux_2_17_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 04cd5f6ec450e65e777b55924969aca34af8c8b64681d394c606166a789fec76 |
|
MD5 | a749ffd4bb3bf5bb8765144a026983da |
|
BLAKE2b-256 | d9b7fed5cdf917be11a21bdadb2afdd7a6078c872b06b62bfb21bb79d41a0173 |
Hashes for nostr_sdk-0.10.0-cp311-cp311-macosx_11_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1d97764b7d312b199c3c16fd3c099db658c73bb5398c26244912ffd18ea739d8 |
|
MD5 | 2aaa93b9f968885d4e4240e56a1834ca |
|
BLAKE2b-256 | 344344aebe57e70ff34627f070163004944f9a28f06e1a7cabc38455ccc30ac8 |
Hashes for nostr_sdk-0.10.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9a8e34dd443f1c58428d1f00ecbb3ef0000522ba9349b0750d10bb88e6631a80 |
|
MD5 | c4b7d0121164ffede0ca05f1b78218c6 |
|
BLAKE2b-256 | fd71744b714f394e0caa44045bc93281f4c312debab4f6cce526f1458a2efbda |
Hashes for nostr_sdk-0.10.0-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3e63c6e322c2b7251b97de6fd9daf31a254712be23fd5e22d4a49a846c2170a6 |
|
MD5 | 5d64547059b2c76b49cbb4b5ab18634f |
|
BLAKE2b-256 | 0ad0bf6512f1b6d28d2f64b234c80f3eda5c0e317f62242e911cd6f1ebda26b5 |
Hashes for nostr_sdk-0.10.0-cp310-cp310-manylinux_2_31_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | af92766a9a1e212a9ab665020827fb4cdba3710a3932e637dbf9469c511e89fa |
|
MD5 | 55c930acf50491babeb5852550b39ce8 |
|
BLAKE2b-256 | 557696aee5cdbba8d4e9a09fa4daff5dfb83b9ad0fc0c7ef327d563979d15318 |
Hashes for nostr_sdk-0.10.0-cp310-cp310-manylinux_2_17_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 817b2d19ef5e9b4acc29e97b808dd6b8cdd946f89fdaed48200d3346775317ac |
|
MD5 | 2e3c22285a8fe724368e0fa623e92bf9 |
|
BLAKE2b-256 | 6e9a4c37ac85f66f53b547ffd5c69e1312336c4c8f4c9c95616a4e50d156d326 |
Hashes for nostr_sdk-0.10.0-cp310-cp310-macosx_11_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c6e4fddd8537de17c18c0bc6677817affaa7b91ce2c7648d5d24acbb1f7851be |
|
MD5 | 79883de7fc29f36f90e2b377f859d7e6 |
|
BLAKE2b-256 | 0868e1ddf4db11bf7e05ad677302213cb6307a6bf50f4f63a9a006e4e1fdb1c8 |
Hashes for nostr_sdk-0.10.0-cp310-cp310-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 64184379a8cbab44be36aa1f64eccbf18c1ec585d5558fbecd7dcc8ba973095a |
|
MD5 | 7c55665f95c5b74bc5ceea9211e282a7 |
|
BLAKE2b-256 | 6ec80a7d045c8e744c4ea2dbfaf98cd9dc19fb0a81b90df85eefa3beee89718a |
Hashes for nostr_sdk-0.10.0-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8c8e035e3fdb1652cf96dd0b252f6fb12e82cec102bc19a09b2ec658187a5337 |
|
MD5 | 0f1ca7a5b11c279ad50bab6783153bd7 |
|
BLAKE2b-256 | 826347faf6879b2a0d460e0dc6db28131e514496b45ba28c34565907dfd8718d |
Hashes for nostr_sdk-0.10.0-cp39-cp39-manylinux_2_31_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 702892320f607e63762502c926685c10ea169657f17c5cb9588ec5d1cd064b8c |
|
MD5 | d9338eaa556a7b250c958d4cf596451c |
|
BLAKE2b-256 | b7fb05d1b6192bac5891e592fb6f57826b65c97be61169aaae5830d08f108af2 |
Hashes for nostr_sdk-0.10.0-cp39-cp39-manylinux_2_17_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9395b50bc4f4a90bf6521ed6328db25905b8006df5b648d2b1677a75d283206c |
|
MD5 | 628ea3796b1f77ef50f2b431b0622822 |
|
BLAKE2b-256 | 4afa65ffecb1d64a962a01867ed427666cf6eea01f46ba8195821f3138c66645 |
Hashes for nostr_sdk-0.10.0-cp39-cp39-macosx_11_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ee16f650bc16214c576e5d9d5cf31bacdaa1310f36081e9c213080dcdf20cf95 |
|
MD5 | 49737c0e8441da1776ba959da05ffe1b |
|
BLAKE2b-256 | 1b05b77eeb0dbf47c551d7bcc0b792b965c00fdbef27d65def3777e1e93d50bc |
Hashes for nostr_sdk-0.10.0-cp39-cp39-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6451b5fb7b8b7862f48d131e943f0b0e88de6dc30a8d10e6b313c22127632ddb |
|
MD5 | c5dd864295838d3ec0cacf8344b4faa3 |
|
BLAKE2b-256 | 4b4b2f0b255396aebce4c52f40ba66771962b2fa09852367151bff419fc68e9e |