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
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
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.12.1-cp312-cp312-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 54b241818c2ac9e9bf0db014b1bc541e03fdcc40b682e89de358d50e579bb9b1 |
|
MD5 | dd3945aa07552cc445c1e7b75e05ddcd |
|
BLAKE2b-256 | 5583b202cab9d45df22cca33f676267402c6c08a5c1ca31a3d0c9ba1d7d65c35 |
Hashes for nostr_sdk-0.12.1-cp312-cp312-manylinux_2_31_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 810f9f2231fcaba09cb7da016a50193471db848d92b84ae39591868361d98988 |
|
MD5 | 94e1d8eeb8727ccc333d61339b8a81c4 |
|
BLAKE2b-256 | f23c0da66143ec7164ac1e5a495ca1f12aab6ba2264c56d3988eb30e990fa742 |
Hashes for nostr_sdk-0.12.1-cp312-cp312-manylinux_2_31_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ee86f08b47229256bddbb11211d796dd7739e77374a8f14a0f4b77ab5b3b16e8 |
|
MD5 | 8f945ac23f3bacfddc2ffe854f35ccaf |
|
BLAKE2b-256 | cacce0ac87e6b2b0816bada0181b8790d8934589f605722072e1526202be4054 |
Hashes for nostr_sdk-0.12.1-cp312-cp312-macosx_11_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3c550e4ae80c2a54b734907e1155f9a8a755a445ca586bd513b3f7ef480f502a |
|
MD5 | 3083b08ea23e1b6af24f4787b694c884 |
|
BLAKE2b-256 | d4b8b6d29917e294435e2ed8132760ac0394174a6fa77d9f0dc8e298b20eacc8 |
Hashes for nostr_sdk-0.12.1-cp312-cp312-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b676b44bdf5485806e8b73393df092099f6a854ca6936ad0206e5f52fd01d711 |
|
MD5 | fd5a11eb041117f5acd709721bf2c5ac |
|
BLAKE2b-256 | 12a2c7982030d25636e89cb835cf811edd78cb46515af693c73472dccb841229 |
Hashes for nostr_sdk-0.12.1-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2747b67f6d2aba28530ff25c5b997abc7c8b52699c3cfd551a80b7d2e125a48e |
|
MD5 | cdf72e3dcb77f968a20b0088df691754 |
|
BLAKE2b-256 | 71257204b162d5355c809132cc0018456036a66a0138d379d8b92e17f6873479 |
Hashes for nostr_sdk-0.12.1-cp311-cp311-manylinux_2_31_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c04e3384fd003dacd159192321c1b5cae0aee6595e891a504162537fb8c817b1 |
|
MD5 | a5773dd82105f42ba859dc654864159d |
|
BLAKE2b-256 | fbc754ea85efdbd6a0c40f701d4ebf5c855fed3168101992db28e5783ef46bb6 |
Hashes for nostr_sdk-0.12.1-cp311-cp311-manylinux_2_31_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5ea9f378260490b6447bb93cee6b83024ec740272572020cca119b26f28d98f1 |
|
MD5 | 558cb3c6cdefc152a18ab864e7795fd9 |
|
BLAKE2b-256 | 921fc178c9175830e3a6e8ddd88dd1cfd059f571b14a6091035dbedcabc97fd3 |
Hashes for nostr_sdk-0.12.1-cp311-cp311-macosx_11_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 28524dadcb9d540f7f24ce89121498d176a4315d8388903e3e7816773323cfdc |
|
MD5 | 03c15abc3b56e0a5119b859fc75bf2f3 |
|
BLAKE2b-256 | 0137f2f949b40bdde3caaa52e681ca28334a4d4c8044850747da93f9432a49cd |
Hashes for nostr_sdk-0.12.1-cp311-cp311-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 74d486e473032f17837cc12fd10ab63bffbfa794176328c823763b8971f4c793 |
|
MD5 | 39429428c0095d0106b2a240f73bc55b |
|
BLAKE2b-256 | e16bc4da45724cdce6074d1cedb31a3e8874e6811ce38a4a9a5f59fce595e86d |
Hashes for nostr_sdk-0.12.1-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5d19b6b51730949d11dcc57d3eab1cf3368834a1458ec21556e29d4020208237 |
|
MD5 | feaaa6a4798d66727073ccc9fb070bd2 |
|
BLAKE2b-256 | be9f18f3bce7cf648092cc796bbab4c28aa7588ac9faa1827f27120e5501a250 |
Hashes for nostr_sdk-0.12.1-cp310-cp310-manylinux_2_31_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3138439bb03a685835b22a0758b12e0f6b36708e16f04eab4eb0ecaf663d844d |
|
MD5 | 8946230b75b757a643ab5225f86bd49a |
|
BLAKE2b-256 | 8c8063abbaafd5251352fdc5912132e978ae1f84a007ea231f0bf0a71ca1094e |
Hashes for nostr_sdk-0.12.1-cp310-cp310-manylinux_2_31_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2eca52b5e78d48fd3ac79d943469ec04f04247b74fcafeceee319e8cb0e81106 |
|
MD5 | 4b252152e6d7a31546aaa94992f249a5 |
|
BLAKE2b-256 | 56508f82738b9955f18f7a5a3997edde22639d9ffc229b980d3cfdc11af66e40 |
Hashes for nostr_sdk-0.12.1-cp310-cp310-macosx_11_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 163b6598b75a5e25555717f13a62de166827282e13d35cf34b64ce77d552d10d |
|
MD5 | 89a04f16e2b66a23fc61f9a91e950bf7 |
|
BLAKE2b-256 | 4b8e87b314053beabf28d05abf458c48d7971eff018a09822b52df70b4afe080 |
Hashes for nostr_sdk-0.12.1-cp310-cp310-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 69c6836a49ac37a6be1438794ee4ed895b1425b661c7b7c1c8f0e0ac3a6ad70a |
|
MD5 | 8219d8818552088e9ee4b4703e1ec752 |
|
BLAKE2b-256 | 41a13dd1c2e5f6507262e2cde5e4e1a2145c24949345e3c90570b40e25abbcc2 |
Hashes for nostr_sdk-0.12.1-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e30bb68493770740f846e0dee33de47cd1601377c84d4b625d43c9c3ee9ac9db |
|
MD5 | e31b45e99bc95abcc50a5f98a2ab83b1 |
|
BLAKE2b-256 | 88488162a036728c1d7f9c04ff2eb8d58d2928631d204056c346549a828ff8e6 |
Hashes for nostr_sdk-0.12.1-cp39-cp39-manylinux_2_31_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6a3ace42a2bbac3abdc2f9f464ced61fa1fb199fca2268ee2575bb58ae2b8751 |
|
MD5 | a094ef1b2cc686554dbef3447a69f714 |
|
BLAKE2b-256 | 143f6aacd3217fa0506b6008bde05aaa02958d4c38bfd9214575eb39a9151607 |
Hashes for nostr_sdk-0.12.1-cp39-cp39-manylinux_2_31_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d8f6b7be0cb5a5fa4587502d97a052f613d9e53498c057b8a38ca71e58a4475a |
|
MD5 | dffd799b02144c646a806e75344a93e3 |
|
BLAKE2b-256 | 462f348dc765c440f420782651a83f03ab509ecaf1558bbdbd0766d495c0ad5a |
Hashes for nostr_sdk-0.12.1-cp39-cp39-macosx_11_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d6e6fedf63f432aa328a600dd7da47ca22a410aba4745d796ef5cdaa25226c39 |
|
MD5 | b99e15e829ced2afaa61fead8bd8e1d8 |
|
BLAKE2b-256 | eb9c9ac96725e6617c0d66da3163b9153badac2548ce639463df22112e4d3cbc |
Hashes for nostr_sdk-0.12.1-cp39-cp39-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5e74bc5cccf0fdbf07dcb22fef80a6133d6562c5fecc11a71d28ca8c12741036 |
|
MD5 | 82cf829716052092c84dae4eaa36e5d5 |
|
BLAKE2b-256 | 5ea69fcc4e3a23fac27be21cc775c442a04c017ba7fbbcfe8458679f1a850bd2 |