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, \
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
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.11.0-cp312-cp312-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | efba2ab075e60bf4ef1d93953da89edd2b3c79b7a92b490d7774695706ef14c8 |
|
MD5 | a5123c69dbd35ad9b8a06bc3614c2786 |
|
BLAKE2b-256 | 2636fe2c91b8aea04939f088cf5184a366b34858b7866412dc0dada3b5f6564a |
Hashes for nostr_sdk-0.11.0-cp312-cp312-manylinux_2_31_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ef9de5c28a74215cb381c6004b3cf8b87527212b5f768d3cd432c895e7a2afd1 |
|
MD5 | dd0d353bb9453bbca37995f46b6ffa41 |
|
BLAKE2b-256 | 73e5e364599935256399022152d5e5e78d003ce960fafecbc69dd0699ce26ee2 |
Hashes for nostr_sdk-0.11.0-cp312-cp312-manylinux_2_31_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | eb251751875a379deda5f5b00001dd69ea1f655c0d13f58bc39f463b224e9d27 |
|
MD5 | eda67e00aeb29b813b6776823f437b8b |
|
BLAKE2b-256 | 54e371c26d0ba8ddc9a5677259779532a36ae227a0eb00030e52d7f83db32988 |
Hashes for nostr_sdk-0.11.0-cp312-cp312-macosx_11_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c8a9af2ac95710a575b65f352c6375e80f09c097a0f3c44998a898e5bd685fa3 |
|
MD5 | 8764fd2ad7f93438470b6da76861ecf9 |
|
BLAKE2b-256 | 449430459690a0a4467552bf4a17d9c80f20996da5a88fa4ea8fd1541a67f8e5 |
Hashes for nostr_sdk-0.11.0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 92dce8428dd623383386ead8183394f28f4ad694b2127aa93338379bab229fd4 |
|
MD5 | 5d3cceaa60dfa51475fde01d0c609834 |
|
BLAKE2b-256 | c822b9869b890c4658e92d5bdbeb45e347b337cf28b2a4d127b29d43457377e9 |
Hashes for nostr_sdk-0.11.0-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c37ca037f995a0bd7d183df44b3a650eefacbaef06720606f0ccbd9f47d64e87 |
|
MD5 | f203552935984afdd9af8aa89c762349 |
|
BLAKE2b-256 | 155e69256bac8c841ac6b32966aa361b70d1f40729535b98ef73fd2028841bca |
Hashes for nostr_sdk-0.11.0-cp311-cp311-manylinux_2_31_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 853d5ba5cfdfbb8938dc293e121fb5afdf18da6ac34c6f0a45d6738226daabbf |
|
MD5 | a50db9d646526438872def769b1ed1e9 |
|
BLAKE2b-256 | d7b430f077f36773bee968aede3ad15e7883f0760bc266b19ef08c41f5eb7732 |
Hashes for nostr_sdk-0.11.0-cp311-cp311-manylinux_2_31_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 526ceab4a126d8ae3d71e078451e87f0b2a9af8425c0295de010defdcafeebd2 |
|
MD5 | 6c0809d16707e5c0ca5ea9f16ccdd5bb |
|
BLAKE2b-256 | 50387371ce394481a3cbcc7b58d3dfa6083f27f02e66c1ae0bb9efb7ff509452 |
Hashes for nostr_sdk-0.11.0-cp311-cp311-macosx_11_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3843d3ba049094ea89d8909bf38d3b5e47b260037ad4477cb57e9e0390238fa4 |
|
MD5 | 2e6887bd70cffaf43a8a777c00b15a83 |
|
BLAKE2b-256 | e6a27f1e9fb97d5aa173a52789443fd8008732710b5e58c64d86d0d5febf6922 |
Hashes for nostr_sdk-0.11.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0e8c9aca8c4c85d2f7810f6fabe6c7b6c58baf659ebd79eefd4f6d9e65a5de2e |
|
MD5 | 6ef00a5da2e48dc2a5ebd620d77c98f1 |
|
BLAKE2b-256 | 9ca9af39387ec398f2a6f92d021d60214aed2ad8c08e256909bf4cf451ff5c5e |
Hashes for nostr_sdk-0.11.0-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 994c509534ace04cb6262f1830b088cb405fc46ae34a4dd08ed911866cb4c5ab |
|
MD5 | c52dd6cfc91c58bbc0d5f495a9ae147d |
|
BLAKE2b-256 | 2a0581ef004ff2a2aaf4aa9f370c0ea87239b9f105473f5dbae1bd4788cd45ab |
Hashes for nostr_sdk-0.11.0-cp310-cp310-manylinux_2_31_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1f4cad26ea3449cea72d97fb56af4a82491959e3adbfb2ea76b8ada7c79a6ed8 |
|
MD5 | e4e5a3dcf22ff95c53422e65a38a6075 |
|
BLAKE2b-256 | 76aa4203fe192ab625032fb04fa6a3e155600b78e59d4a70d7f34da41077700e |
Hashes for nostr_sdk-0.11.0-cp310-cp310-manylinux_2_31_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 28a28de9145e04d8bb3e7b222017b95a407da26926fc90af8beb517e70832b51 |
|
MD5 | b4bc8d47c790444118b015177cfdde85 |
|
BLAKE2b-256 | d38a066ed666d92e852d587c1e8e8d24243a8193163cb77f098e3676e606963a |
Hashes for nostr_sdk-0.11.0-cp310-cp310-macosx_11_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f1ca6774682ece51eb73a0352afcdb79ec702d4f347fe4ce8e96074cbff724c9 |
|
MD5 | 60c87d2752099890ae270bbbebad9688 |
|
BLAKE2b-256 | 4b57ff4fec11a7bbb4683d20262593289ae1a6387e7af0b1a1290ceff37bc6ce |
Hashes for nostr_sdk-0.11.0-cp310-cp310-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c2b1ab9cefd968e81815199ae0119749568b968726f81a237086f8eb82571ae0 |
|
MD5 | 87766fd0fefb5ded182f5b90de485694 |
|
BLAKE2b-256 | db7a48a94ee5282bec30bddebdcb6cc1e761cf046a6e608f01e3fae875e7e57a |
Hashes for nostr_sdk-0.11.0-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b8074a2e39a5a3b5a707acb2339dd119836ea54bfc63c8b377c30a5c6c3b0771 |
|
MD5 | 62bb2d2b0605dd247e5853059618e4b9 |
|
BLAKE2b-256 | 30b3877af27031e6c675c013b8f17d93f0639ca8355a5ade39f2a65f64c47f11 |
Hashes for nostr_sdk-0.11.0-cp39-cp39-manylinux_2_31_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 758348a132baa232f08b29842c07b4a24333ca5c8ece2a6e880910f684e39d8d |
|
MD5 | c720f830ac0ba063db28cb93c939984c |
|
BLAKE2b-256 | df41557fe7d65ddadfc61445bbfecb71e15dc901556a2436020d54ed0c18f50c |
Hashes for nostr_sdk-0.11.0-cp39-cp39-manylinux_2_31_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | dfabca1ffb677434e323e760af37b09db0badfe8915daf83c972cbec68080850 |
|
MD5 | 720cc4b8ed8a45c118e13633d6c1bf05 |
|
BLAKE2b-256 | 30593d13923a463e980676fa0618cb886277c25ae67ca7a80fe8c9987cf83b81 |
Hashes for nostr_sdk-0.11.0-cp39-cp39-macosx_11_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 003086d44f331406bba53a80efd0417fe98ef29798dd750cb7562350a9aa205c |
|
MD5 | 11fa5cd6a369418527a578a05c84b9e6 |
|
BLAKE2b-256 | c17b15f9fb45c5af92d3e74823d73ebd7bc884f1fb9067f0ee316b0afdaa49bc |
Hashes for nostr_sdk-0.11.0-cp39-cp39-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 59f63726909260a189012320c0665193e5135d3515160b30e40c6dc180929687 |
|
MD5 | 5b9100b9897f6e436efc5e65918080bf |
|
BLAKE2b-256 | 11ec25949f49bc7ca92a3de201bb772960bd6f9d7100ea7f1fc621b759a7de08 |