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()}")
await asyncio.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.33.0-cp312-cp312-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9bcb84d79789d58053d13081c1fc13d9dc67dd063fd665dd429178d472931cd7 |
|
MD5 | 7482d299e17764367fbcdab3368ef5fa |
|
BLAKE2b-256 | 71c042069c7ccae0502b37780178e48f14b59ad7ba4441842e546a8162956f83 |
Hashes for nostr_sdk-0.33.0-cp312-cp312-manylinux_2_31_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7d5cd4096fb953a3b0ee9e98628afa5a2b32a4859df09e7d022dc3178a8e2896 |
|
MD5 | e089d194a9bded7280b2aa5a71ae6926 |
|
BLAKE2b-256 | 18a0e87a84a708a74c50864783242646fb4721a96f709cba4ec6e6c62be3b684 |
Hashes for nostr_sdk-0.33.0-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1a8002320fb5645d142deddc80b6a74518505db733662b76b31fe841ae183a3a |
|
MD5 | 0a979b498f863bdd01b9cd42be4d5af1 |
|
BLAKE2b-256 | dc7eb1764cd64799725fc3cfe4ddab246a96fbd55eae2d143bf06aca6d496531 |
Hashes for nostr_sdk-0.33.0-cp312-cp312-macosx_11_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2c3ee3b22b23fff3093a0ea9980f01176116b9ad29bfa7703a6f326ec8eb83e0 |
|
MD5 | 1efd8025222a24e770d1bb9eafa19504 |
|
BLAKE2b-256 | 480338ed1a98af0a8dfd8704de302bc9c931cd4eca6581b9ae9001de7a30c75b |
Hashes for nostr_sdk-0.33.0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fee43b21fa30aa41cf343ed86092a876414ea24032ff038f6aaff76e68867fc4 |
|
MD5 | a9ddf7ed4a2595ba8d48c063b06d903b |
|
BLAKE2b-256 | 74f6a9e079f2eb0d135c8260a39a7dceb0ad4d2aaee5d48d47025db27d3784f5 |
Hashes for nostr_sdk-0.33.0-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fb28939586c558112a89276e3ed28fb5e3723867cde5a6d6bdc213677f58957f |
|
MD5 | f827cbe57483223a09e530c7f3c2b304 |
|
BLAKE2b-256 | 4e9456fae0e7c8d0e62f10449ce2ea6f0df2275060f17fc839c2237385c818a2 |
Hashes for nostr_sdk-0.33.0-cp311-cp311-manylinux_2_31_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 005ed0c719511c64d0c28adfb6793bebd62b7ca18e6fad094a32cb741aa4ecfb |
|
MD5 | a997e88d3bb797ad3d949f7402d8ff27 |
|
BLAKE2b-256 | 385ab6f964aae35370f404c170dd96ffc49eaaf55046af8ceacdcc94de90d345 |
Hashes for nostr_sdk-0.33.0-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0245abc017196bc3e86bec3e20b80418b4cb28b330dd5033c8ab32083dca8687 |
|
MD5 | b97df933de88068d16cf348db2e6f912 |
|
BLAKE2b-256 | 5dcf926d71adc4d74cb89327e198d73f365eede379847116d59a53faec9dc2a7 |
Hashes for nostr_sdk-0.33.0-cp311-cp311-macosx_11_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8546c5fa7f0025b1168ead204b1ac7151e9818ab18a829f0ac21f80e49927c18 |
|
MD5 | 4b825489a40bbcb6618627dac42502ab |
|
BLAKE2b-256 | 46887d3f77468c57bc8d7ad0b1672e40991b501756b6490bd7020cd89aacfde0 |
Hashes for nostr_sdk-0.33.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3ee719b6df9db6dc1d85c9f391fa886358cdbab3a51e930823af686b3db06677 |
|
MD5 | b2ae1f3d4fc52c046d9e2802773620ed |
|
BLAKE2b-256 | 0ca1635c03b66ea7039faa7d23b18f4130f6379edbee57d6e5435ad9ea1924a1 |
Hashes for nostr_sdk-0.33.0-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d0f8ad2004319efceda079d7bb1ea32a541a8446b3ff87cb98c38cc57eb36935 |
|
MD5 | af40a0c7cfbd532e00ec258c1a985dd2 |
|
BLAKE2b-256 | b269826892b93f6187436d37e3d8030a8d8ac53ed2a0292d7c12c2f552792ec6 |
Hashes for nostr_sdk-0.33.0-cp310-cp310-manylinux_2_31_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 66aadcb22be601e35bdd7748254f0145467f3c9402bfde236238c4ce2f593186 |
|
MD5 | 38c89c22d37f0ea16f6b25983a636d42 |
|
BLAKE2b-256 | a61604c72d539160182735113cfae39ff3ccbb0926999351dbce9016dc1855fd |
Hashes for nostr_sdk-0.33.0-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9fd31b9adc9091613cef10ab521966ce41ce6041b21b84c1b7178b295022b4be |
|
MD5 | 867f9e67aed428f70a01787da4cb4b3f |
|
BLAKE2b-256 | 07e2bed6e42318dfd99eb002a51a1425e34ea8dbd4c3d99a9b68d3bc70c54308 |
Hashes for nostr_sdk-0.33.0-cp310-cp310-macosx_11_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 59f837246de1b164827c65b344ecafab25300e356de089344c9ea09b1748aead |
|
MD5 | 2799d51a27b913c2523450e396321dd0 |
|
BLAKE2b-256 | 73f6ebd33813735fa9c31004764f24a9ff253a2cdf0934d266d3d3041e3469d9 |
Hashes for nostr_sdk-0.33.0-cp310-cp310-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1efb65f24e35092e046b484ba55f8da414b0666796461f146f121162736fa8a8 |
|
MD5 | 69cbf876c94e6de4638dee90dfef2d04 |
|
BLAKE2b-256 | a6250bc25aa7ac050957b75fd08b9784e64714489e7c7139ad04aee583083bd6 |
Hashes for nostr_sdk-0.33.0-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | aa48f5145e2072dd7f97bf0035241fd92589c6dbe20561ab53c7b7b4939eb5a3 |
|
MD5 | a55237cfb219da677c611d9779143baf |
|
BLAKE2b-256 | e95592e50d4e6e2835d6c705718144b7e684bcf65db32bf8719f1ed6e132f20f |
Hashes for nostr_sdk-0.33.0-cp39-cp39-manylinux_2_31_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ca8c85022a58e0758b084b11d68820cdb748978e7b733e0bc6498728be12c985 |
|
MD5 | 87ddd190710f0ab90915584a91ab2ef4 |
|
BLAKE2b-256 | 51149102adec934a2acc82534e26fb7dd34c3a320322c4f0a8b365b34d273348 |
Hashes for nostr_sdk-0.33.0-cp39-cp39-manylinux_2_28_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 546142a0ec0f0c39a50ee7809f81d0241441da11658f7d77b916d4928dfcd54e |
|
MD5 | 3885267ec7d0c7beb499f4e54fe05251 |
|
BLAKE2b-256 | 3bfe4474a2b696a3ce93f54915cb1d84556c2ebcfd772aa7a224c2f8ef0fce9c |
Hashes for nostr_sdk-0.33.0-cp39-cp39-macosx_11_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 676008fadb1b9deffedce66d2782282d208d3818a666722e0fed60d7a2a7764c |
|
MD5 | 78083db5199cb99637c2afd02c6a5c13 |
|
BLAKE2b-256 | ecf34d5c52044bd9f7e9f6b62ea09e2918b61e32ffe82941cdc456af657397ef |
Hashes for nostr_sdk-0.33.0-cp39-cp39-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2f40c17b4b9298b50d7430ea394bcc4508a4b4336d116de385109f7341c81ce8 |
|
MD5 | d43836bc504970f1237ff664908bad2b |
|
BLAKE2b-256 | 3e62a101a3a2ae06427d77fd0362f0b09a798dfd052a54ed3735a7284881b326 |