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, ClientSigner, 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 = ClientSigner.KEYS(keys)
client = Client(signer)
# Or, initialize with NIP46 signer
# app_keys = Keys.generate()
# nip46 = Nip46Signer("wss://relay.damus.io", app_keys, None)
#signer = ClientSigner.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 Client Signer
builder = EventBuilder.new_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.new_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.
License
This project is distributed under the MIT software license - see the LICENSE file for details
Donations
⚡ Tips: https://getalby.com/p/yuki
⚡ Lightning Address: yuki@getalby.com
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.7.0-cp312-cp312-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 61ceae275536ea208492da3c96ee04137a92f59cdd4f1e3139516d4166ec42b4 |
|
MD5 | 7bfdb81c9a6b1fecd15896367869089f |
|
BLAKE2b-256 | 19dc12d0f2df39a1d33dee6a0399cb950994999d26d9caf9ef73965ed075388c |
Hashes for nostr_sdk-0.7.0-cp312-cp312-manylinux_2_31_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e49daedad30353d835c8a121f37ced315585c326a8a108def6e0c20e62cee778 |
|
MD5 | f46692ad0697a92adfdfd28177299bc3 |
|
BLAKE2b-256 | 18f32ed29890008126d2085133435fbc0a89b8fb4a2411f461207e01746e75bf |
Hashes for nostr_sdk-0.7.0-cp312-cp312-manylinux_2_17_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | aa7205736baed4700a0ca2c31819b27fa4810079efe45a21dc3a7411ce6fd438 |
|
MD5 | 609d3fbc8d200529a7ca7cc30480fdd7 |
|
BLAKE2b-256 | e707ceb019c60770c0f53547dfa36c42160783172144ec77ca9ce74678b81315 |
Hashes for nostr_sdk-0.7.0-cp312-cp312-macosx_11_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cf07c57415e40d00394f09eb1ed60275a17802b93f3f4b9b4625e20998770e5f |
|
MD5 | f520dddc7516ec90e1f68a105f67752d |
|
BLAKE2b-256 | 232430d4d01437f163faf694e2e791cccd67c8e598bcdf7d3b126c97f1b98c1c |
Hashes for nostr_sdk-0.7.0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a0f09f63ba0b0dba34ba957978087ab34041d8dc0bf56e69a96e1f8343d37b6c |
|
MD5 | f2545b1a1b6052740263030091bd300f |
|
BLAKE2b-256 | 9f8c461284a9db203461a242b7301204ebd462d450ec69eacd45cd67d9377633 |
Hashes for nostr_sdk-0.7.0-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 37fe704f983497a1481c4fae02ab404208d2dd52e9f83b896d47c2bf37ff2227 |
|
MD5 | 62b2e0d2464e7e435242ae3fe6d4c3c1 |
|
BLAKE2b-256 | 516b1792dd3d749928c0bba6bec1bf8ae03cb510cad7017f357e8ab82615a55a |
Hashes for nostr_sdk-0.7.0-cp311-cp311-manylinux_2_31_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 601e7b1838a22ab1f8742abf7da91b7380176f8cd0f1acf6853057ecad0b5810 |
|
MD5 | 298694cfb2c5c3abc05b1153f2492914 |
|
BLAKE2b-256 | 778dfc10a6231cdbfd13679965f1027e84afca8e4b1dff197165805514461aa7 |
Hashes for nostr_sdk-0.7.0-cp311-cp311-manylinux_2_17_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f68dded5961c7fe581bbcbaecb7f8c11cacd478cecd18d93b83f5ef1bf4a6f34 |
|
MD5 | 717898331ae504e4ebf1566d65c0596b |
|
BLAKE2b-256 | cdbff157a1717cef1b2f6c7ab8dc338cfab6a3820cbbfd701f775e2cdf73eb16 |
Hashes for nostr_sdk-0.7.0-cp311-cp311-macosx_11_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 654a3da74b0344029f7b2b7fe57970af905256e18148d57f211a659a5c85d528 |
|
MD5 | fb56479ffe4447de20821c7c252553d7 |
|
BLAKE2b-256 | 0f29df89d654969573077d206cf28cb9f628f5d9a2cae2fb7f332a77146382af |
Hashes for nostr_sdk-0.7.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 100e43f2c7d412a375e1cafede2c7af21680321a978dfda2c9980075e9b5b70a |
|
MD5 | 3a8c45ad28205394ab0e68f9aa756ee1 |
|
BLAKE2b-256 | 9e3424f7d7ca673af8dfa104bd61bd973c4db0311920b7d9d3e7f905e85e63d4 |
Hashes for nostr_sdk-0.7.0-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b70c672ca1203f3bdbdd554f193f25000796fb675d6cfde5455c4fd573f4417d |
|
MD5 | 79c88adb2163272a45cce9a58c8a12a9 |
|
BLAKE2b-256 | 354c868929d7a5c83d7abace2186404d5fe23230055fed60809803b4a033606a |
Hashes for nostr_sdk-0.7.0-cp310-cp310-manylinux_2_31_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c6e8642e7c17322dc3ab69c5fb0fae6d450db425e3362a6b85b0d69c134da868 |
|
MD5 | 4a6cd1b3cd398a7be2158cb617116580 |
|
BLAKE2b-256 | f8ef36f733f1c605788e82bf1aae8f554f862f72bfe4f8f45a5f9af5fa9913bf |
Hashes for nostr_sdk-0.7.0-cp310-cp310-manylinux_2_17_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0b99dace8ea22000a9bf7d8b52de4b0494808b20e96103a82fcd099b97f82f8c |
|
MD5 | b970f4c865531a20960ed486069b6598 |
|
BLAKE2b-256 | 214d1200071f03c00a01fcaed864c604cab7661224bd45a9e3ad17715dc6d65a |
Hashes for nostr_sdk-0.7.0-cp310-cp310-macosx_11_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6956695bfe8b2277dd2589d314a30fa4360c45d6b717234cc4dfcd5ea6862d8b |
|
MD5 | 6747a7e620ffa3591b30fc238a4e8e35 |
|
BLAKE2b-256 | 70bc7fef176f2b107bde3fa2c3dfc4cad3925a9979453eacf96a7b2540c8e986 |
Hashes for nostr_sdk-0.7.0-cp310-cp310-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b6bd36d9782afa6b4083994e114afa296ee14bfd4f3b1745b5418dcc62ae0862 |
|
MD5 | 85b237322486132e50faec2d926afee9 |
|
BLAKE2b-256 | 23216860efa64526637a0f50d7707cb01e296157c5a09cac257c5dd4e8cf56db |
Hashes for nostr_sdk-0.7.0-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2cdbb14e0978c3cd7e01224ea3bdd35d9001f00534d30e126882a7689cb1ba84 |
|
MD5 | 36c6bd03dc96f34e3c6e5fb904d883b7 |
|
BLAKE2b-256 | fe2ca13ba0d362de83dbc7a9c5f2dc92b58ca4ce6d492bb2b573911495d3f681 |
Hashes for nostr_sdk-0.7.0-cp39-cp39-manylinux_2_31_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b42e578d890969a8980b4a48d38cd4729905c45f31c8b8e987c2b2a82ce38fd6 |
|
MD5 | fb177c88acf58d037c33c44b12be5303 |
|
BLAKE2b-256 | 91869ec249d287db78c1641f885700313fc89c3b856854499c50a2f8129e7267 |
Hashes for nostr_sdk-0.7.0-cp39-cp39-manylinux_2_17_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3544cf853eb041a23bd1767fe57f8c102154b8aee3d038d53faecabe13df812e |
|
MD5 | 67dd3e783c60c2703f817edfdc244951 |
|
BLAKE2b-256 | 5890fe71c38e1c652f6b132959c303f3754ac721586bc90ba17f36f29c5fcf45 |
Hashes for nostr_sdk-0.7.0-cp39-cp39-macosx_11_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2c45668ceb8f6b771ba50ff78569a601411eeb8019962fdb10f2b5edd606ca22 |
|
MD5 | 99231eb7ea64cf5c1c2c3b6846877929 |
|
BLAKE2b-256 | 20e3b5fb12ff82a9910bfe3a1edbf9e9e4350a093789d7c3479b8da3860ba8ac |
Hashes for nostr_sdk-0.7.0-cp39-cp39-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6afaaf5447baf93a437a1abe80952f6c09971abf1e3e1b2a876ae1f9353707d8 |
|
MD5 | 8c3c0b73fbffbd93700415f59ff3d4de |
|
BLAKE2b-256 | a568fb6fc819ed7581ac2eb5a1ce3d83acf3ddd1b891a96bad00b942c9f36f1c |
Hashes for nostr_sdk-0.7.0-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f67b6f6482869f282e2c3333261878565cfda7c7ef89dc58661c7ab2207732b5 |
|
MD5 | 41dd8de2839af15612c3aafea70bffa5 |
|
BLAKE2b-256 | fde66e6136d65a489898aaf8b46de48a5ca0863fed13a361bd44bc2182bbec49 |
Hashes for nostr_sdk-0.7.0-cp38-cp38-manylinux_2_31_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 93a0c7922e670f9527fc8d6c6d7aa07cd3974717eed782853ec263c058d8ffd9 |
|
MD5 | f28395aad633c21a7cd0d716ffeb4ffb |
|
BLAKE2b-256 | a396fa1d7493b8069e1ae0835314ad4072ce5aa20461eb2457155b013b869bc2 |
Hashes for nostr_sdk-0.7.0-cp38-cp38-manylinux_2_17_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 706edf529c2dbd3e6ac238c2379a8b4b433d8d96e5a2dc562f5154134a51552e |
|
MD5 | 5712551d1bc9a2e46b12defb740b3fab |
|
BLAKE2b-256 | ae5618eb3891d995467aadf9542736f1a2eab39381f1597112d8c36920d0416f |
Hashes for nostr_sdk-0.7.0-cp38-cp38-macosx_11_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3aa860f5652df4b96b2f04ecd4679a450ce9909c3b0025f71e72afcafe39fc77 |
|
MD5 | ec1c0499fdae1312802fddd501e99015 |
|
BLAKE2b-256 | 036655265fa00686c2d2f26240d330796b808da39f79807370ea53a1eb3733d2 |
Hashes for nostr_sdk-0.7.0-cp38-cp38-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3ae1902d8d1b468ea56d278f6a7f07c0268a9205ff7975672099e2b507c41202 |
|
MD5 | 8a18c6ebb7d4aad103a068316dfe74f7 |
|
BLAKE2b-256 | f8dcdee5f07d917d28a90cb1156431b19803b575c706f90cef0b9cdfcc08d243 |