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
import asyncio
from datetime import timedelta
from nostr_sdk import Keys, Client, NostrSigner, EventBuilder, Filter, Metadata, Nip46Signer, init_logger, LogLevel
import time
async def main():
# Init logger
init_logger(LogLevel.INFO)
# Initialize client without signer
# client = Client()
# 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 = await Nip46Signer.init(uri, app_keys, timedelta(seconds=60), None)
# signer = NostrSigner.nip46(nip46)
client = Client(signer)
# Add relays and connect
await client.add_relays(["wss://relay.damus.io", "wss://nos.lol"])
await client.connect()
# Send an event using the Nostr Signer
builder = EventBuilder.text_note("Test from Rust Nostr Python!", [])
await client.send_event_builder(builder)
await 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 = await 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 = await client.get_events_of([f], timedelta(seconds=10))
for event in events:
print(event.as_json())
asyncio.run(main())
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.13.0a1.dev0-cp312-cp312-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e8a20b2b77755d6c4b358a9bec72a13528816b0942906c0ac9f96b33966b71c1 |
|
MD5 | f463ab6ee3f204e9e043ccc63ebb4092 |
|
BLAKE2b-256 | c780317d8ae42a162a2fe2995a71628f5c9e7920590314906b100e85dd4c3d68 |
Hashes for nostr_sdk-0.13.0a1.dev0-cp312-cp312-manylinux_2_31_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 61f357c374e827c45ca6dac304961a534044099aa76c0fd3fdd0a4d4cfb9b37e |
|
MD5 | 8a378b8452a1bdd51f7d667241293e5f |
|
BLAKE2b-256 | 11b61630d3c8d95baa5cb258e050cebc1422815e24fb4b5cdda61d6a89e01d8e |
Hashes for nostr_sdk-0.13.0a1.dev0-cp312-cp312-manylinux_2_31_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9694f9b91c4d307bf3c278c35c5c2c18b3b0c156ca84971744af2a9c4b6ec15f |
|
MD5 | 88ca14143650aa608e48fede272359dd |
|
BLAKE2b-256 | db05abffc66b0e0f2f3bf9464c5fd4ae8a1e748bfa387da93a4411e45c215854 |
Hashes for nostr_sdk-0.13.0a1.dev0-cp312-cp312-macosx_11_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 49f0d79c8ac56d553d3bf138a57df9524c931ac73c6158dcec0fa36835e7c685 |
|
MD5 | 75dec4a637046c5a710512365b033cb8 |
|
BLAKE2b-256 | fa6ba3bfdc2c2be41334e425d89142991243b07d0e7de93a6df987c94df3cfde |
Hashes for nostr_sdk-0.13.0a1.dev0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8f83ca0a5d194578bca891a90187e78031a44fb6b0e8050eddea54fe541aa7e4 |
|
MD5 | 9e4f364c9960618fddc7cab559517363 |
|
BLAKE2b-256 | 82d3ef476e45a0e25008fa802eaf3bfc4fec973bd7cdc0fe8216c45d338871d8 |
Hashes for nostr_sdk-0.13.0a1.dev0-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4851b2782c2a2f48224e1f074c245eaeba03c480516caf6e42fc56d13bf6d8ca |
|
MD5 | 2447bad4c11fa697a4556a89217c48ce |
|
BLAKE2b-256 | 5d50681dce74ee48a688372a7399958e7ca24910718e7d27e5a02409458b4ef8 |
Hashes for nostr_sdk-0.13.0a1.dev0-cp311-cp311-manylinux_2_31_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6db0da24274f9a2788f53e6d4e7770aff8ed0e9ca231647f68b3af36e6d493dd |
|
MD5 | 5f224205d9189a75dc9c54d481e74979 |
|
BLAKE2b-256 | 9ee5af02c7150ce0ea7d661cc49d9478c21f82753b3ddac84c3f103efa015be2 |
Hashes for nostr_sdk-0.13.0a1.dev0-cp311-cp311-manylinux_2_31_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 07e7576286de23a95f725fe7b2e6b2460c9d89fbf35c7fcd04abf17a47a93a80 |
|
MD5 | 76a73092c644af994c92d828e6ec262a |
|
BLAKE2b-256 | 214bbb6bd7043fceae979e14092670321c90bec800f8ccf387612c223528c1cc |
Hashes for nostr_sdk-0.13.0a1.dev0-cp311-cp311-macosx_11_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c40cb2255a01196e1ad5860a6556e0894c2f1687ed25f5dd1a5119abdadf5939 |
|
MD5 | a2af533785d5ca7ffa07f9640b7a256f |
|
BLAKE2b-256 | 36e7961bfc9452de36df77f401813a6221377576d025c050111a2f9435c93ed4 |
Hashes for nostr_sdk-0.13.0a1.dev0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1110cb1d8d98447df8db3c75256661e64512e972c457aff39941229dceb0b73c |
|
MD5 | a5fafe5c57bc5f6600f20599e4812660 |
|
BLAKE2b-256 | a324a1d033d013594ece6b1ad1cec820e8748d259b9df60a4f03affc305b8a0c |
Hashes for nostr_sdk-0.13.0a1.dev0-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c33d4e9fe1820038d7b2ea1c9695d746e3983374f1a7e960d7305893bbdc5d4b |
|
MD5 | 669705b6bb408db98105cb17e43674ee |
|
BLAKE2b-256 | 05999aa77ca7c6de0fce08c65fb7ae262266f8293771c741186cf5974799aff0 |
Hashes for nostr_sdk-0.13.0a1.dev0-cp310-cp310-manylinux_2_31_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b30516173173a9901fb1c576f677346fbd839f8f58d182ecb81638d766ff4988 |
|
MD5 | 5c328202eff2f8148216b8572eddfff7 |
|
BLAKE2b-256 | 30803249a80f8efab1f5d467c315c23e03bd03a1745597c911319a1d79d3a6ae |
Hashes for nostr_sdk-0.13.0a1.dev0-cp310-cp310-manylinux_2_31_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e8cd7eddefe51507bcf941951e69fc23062c9ca9ab0217508c7db85179c69e5f |
|
MD5 | 66f49d1aee501c3a1ea94aa595941cfb |
|
BLAKE2b-256 | 6822384cd0109fdfabaeab1da9f5f79d693b0274fef0341185a2f7d3c087cf6d |
Hashes for nostr_sdk-0.13.0a1.dev0-cp310-cp310-macosx_11_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 21ea873ab46574cf73c69dbcc0e89422ab73510ec99e976ce22c29a0f85499ef |
|
MD5 | 176b125d3c0190dd1c10dffb2869459f |
|
BLAKE2b-256 | b8bf6e28d48a1cf4641ec588b15f6f69f22b2e7439511e7e1acceae994b77278 |
Hashes for nostr_sdk-0.13.0a1.dev0-cp310-cp310-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b64376e538a6645a620b21b219c9ad6d792877640a38e42e94aac171d08509d2 |
|
MD5 | f3ce8e1237e062e17cf15bb5b89878af |
|
BLAKE2b-256 | 79d8d7bc7eed34cfb9d31a420bace243d1ac8dc9e9496c8150946b7f7daa8c32 |
Hashes for nostr_sdk-0.13.0a1.dev0-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6437cc7acdf54bd6245bb7790454b7b82a05262deacebc2d90e04f36e4f89bff |
|
MD5 | 88a915801678609e3d240a76ffdf0bfa |
|
BLAKE2b-256 | feda829dd51039e8d8213bf043e781c580fbc2373ae35e8c90611b6a28903cb7 |
Hashes for nostr_sdk-0.13.0a1.dev0-cp39-cp39-manylinux_2_31_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8d3199079f90abf308ad92bb147ccd24bc86a5aabd32079a28a564bc6f1038e1 |
|
MD5 | 8f16fb490f1002de088d3cc1eea05964 |
|
BLAKE2b-256 | f8aee9c147c1bf71cbbda0539947a7a8a62bdeacfa7340d07a90b653ddcfa9c5 |
Hashes for nostr_sdk-0.13.0a1.dev0-cp39-cp39-manylinux_2_31_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a2863c126bef9e4dc0273704fa1cec0c16483f55f2fdabb8646acd900f8bd20b |
|
MD5 | e3c6950e4c72ff31069359e96ee66032 |
|
BLAKE2b-256 | 2447f4d41304fd2771186e608574777fe1cf7d5de134ee250e73a5ef6a03f6b5 |
Hashes for nostr_sdk-0.13.0a1.dev0-cp39-cp39-macosx_11_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5dc9a05cec0249317f24c447f766a0b6e4529afde98b761206a7b30c3e56ef48 |
|
MD5 | ee21e5c840c74659995b2edd8a35a6f8 |
|
BLAKE2b-256 | 6010038cc84f0b6f815815083af74ea175901f0df392e61bf59b40ea8d17b411 |
Hashes for nostr_sdk-0.13.0a1.dev0-cp39-cp39-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d34546a3c40debe177d934c70e59eb35a27465220ea1b4eafab34a9ce7460027 |
|
MD5 | 590e40807bc8ef9383d91a9aac2d6ec9 |
|
BLAKE2b-256 | c84935676d3ab66a4a50435e1133f11b217c8d40af385f50614103464c13bfce |