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.32.1-cp312-cp312-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 67076c620c2ed81cb4027b5b4f12b1fd5bc5ff04308f3e522a2fea71ab1751f1 |
|
MD5 | 9d2de5a5a5a393afa5544451c8e74c4f |
|
BLAKE2b-256 | 47a72ff24031fbbb6610fb771e59861b4bb6195dcaf419bb28adb143e715608f |
Hashes for nostr_sdk-0.32.1-cp312-cp312-manylinux_2_31_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2b8687b3f1c2bcafbb48aa8fc3d56867d99cfccebc3a49e42fec256bfcfa9ec5 |
|
MD5 | fe7dd7bae227e68bc388f6d7a8a60b19 |
|
BLAKE2b-256 | 309d7c07719c1360f0422f9333b742d6519cc0c55e06055ac2d01f1e583872d9 |
Hashes for nostr_sdk-0.32.1-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | db5b7bb476f539ef048cf8a674fabdb995e44b78255ec7e69deee1bb0a5d0722 |
|
MD5 | af8800bb8541109772fbc1ef83ad855f |
|
BLAKE2b-256 | c03501603e6a8018027aa106d1c77fb8365736c52e2246b2f951ff06db27a311 |
Hashes for nostr_sdk-0.32.1-cp312-cp312-macosx_11_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5e90157f17b9eb2ba6296bc5eb66112537e40795b3401c12aa4b94af7af80f70 |
|
MD5 | f333848898e99dbea7714641e939122c |
|
BLAKE2b-256 | e2c68e1bffd5703ff60019cc61ed716077aaaefc96bbef80925aac781642e003 |
Hashes for nostr_sdk-0.32.1-cp312-cp312-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 515a43d6b0a7fa6a10a9a7e41e65b8dcef51f70f3fa524ce16ed5ab80ae8b722 |
|
MD5 | 35a93c068af2b761cfd329b0feed6eb4 |
|
BLAKE2b-256 | f95422d82bdee0c329d1d54f02665f97c33f5e7aea63911aeef8e15183dd0c74 |
Hashes for nostr_sdk-0.32.1-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 47299cd8f014f573981167f729be2a59ffb202aec9c340b32c2e8d28a300ac67 |
|
MD5 | 04a2882724c22645e116ab36d50205f2 |
|
BLAKE2b-256 | 22a9a167a2cb1c9af5ea4817810a0fa6fb2169da13777e32951c005c2b4cb64d |
Hashes for nostr_sdk-0.32.1-cp311-cp311-manylinux_2_31_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cab53e00532802e1e5387de6793d595c5a2938ff5d5ff3b9bf05d6d55812dda5 |
|
MD5 | ed76ef117a4219f868fbcfd879cd68f3 |
|
BLAKE2b-256 | ab8a37868bec07fc65eb6a60e03089c13eca2887a30cb810657726381219b461 |
Hashes for nostr_sdk-0.32.1-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c56dc7d1756753993de32deb47f643417f67628e9951742489f8638030b53a69 |
|
MD5 | 426c6aa890489b1efd5e4a4c0082b605 |
|
BLAKE2b-256 | f33b07701c637dc35b00a668acbc41ac1aee3d0b0c983402e1a199c257da2b39 |
Hashes for nostr_sdk-0.32.1-cp311-cp311-macosx_11_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0bc694c8c9a78ad3cf253c0afbd8a038f58eecb9ad9f85cc11949e77bfbf21bd |
|
MD5 | 46baa2d8c9cebed5c348fec6c4a51818 |
|
BLAKE2b-256 | bedeabe8d58ba3adeb1088f7f3d02b3969747de0e9e142d2ac8edc78cf44e256 |
Hashes for nostr_sdk-0.32.1-cp311-cp311-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a2f43b2bd37fec1e0e59d4481f7cbb9bcf43cdfa6b20d682bec6199d8370decd |
|
MD5 | 012587dc7701d9950dbd16b169822464 |
|
BLAKE2b-256 | c19a25ef2fe9f521fd99c4d667fa79b3656b0e8fce94b735dc2a58086ac9df5c |
Hashes for nostr_sdk-0.32.1-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 32aaf1919f67b150bb9d3d88df1ff199c3408f93e8e0c9e34731132d12a358de |
|
MD5 | 8dc3d1426c1eaf547a68c66c46eb2f35 |
|
BLAKE2b-256 | 5d410d1fb5740c54f9b2918424618cf73457e798c632ee0c64871176ba0cc824 |
Hashes for nostr_sdk-0.32.1-cp310-cp310-manylinux_2_31_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f9815ba839f7a12e28303d25d6c3ba389a04b129b42973426fd0a27f20d4094c |
|
MD5 | a6b6f15c0eb3e28fe9054542979518f2 |
|
BLAKE2b-256 | 96337ca7b4c3d1f8ad6fd30d778ca000d0e0973da80671fd8148e9d6d5da3bb8 |
Hashes for nostr_sdk-0.32.1-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1f57433ba3c626cc830a48c0e2ace9a145bd5b186087af1b4368b8bf1adb10d1 |
|
MD5 | 9dd1756bc7c8fbcf9965f19a7638a971 |
|
BLAKE2b-256 | 244f5dd077c82f0d48e04081e22213dbb306c14b2a26a63a66dff1957b50e8bb |
Hashes for nostr_sdk-0.32.1-cp310-cp310-macosx_11_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d45603bc0f4d00af7a87914ef90d169aadbc6cbff14dccecdc076db397077b06 |
|
MD5 | 6da170504f0eb426745b117b16afda1d |
|
BLAKE2b-256 | 471584d1ef50c4ef8912280149cdcfa4a385dcd3ff33762b205b2fa3398e0c6d |
Hashes for nostr_sdk-0.32.1-cp310-cp310-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1c8f3f18cf67ed87f09009122b421261e1c315b76b007c98c01357bdd195729b |
|
MD5 | 8b411e86969003fe13515a3ef42ebe3e |
|
BLAKE2b-256 | 9c6377d5a5626d094294a6f75f306960ef279f151f757d739dd3adc405733d5b |
Hashes for nostr_sdk-0.32.1-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b11d420ab562ac8af85cd98ece5337801e2c436515b6f1151d091b547c0e085d |
|
MD5 | 67e5b5726116249f33bb9f8e28487ccc |
|
BLAKE2b-256 | 10ac720abfeab3a711370b1e5529c03d6b3f5bb802de4876996350cc4e4ff36c |
Hashes for nostr_sdk-0.32.1-cp39-cp39-manylinux_2_31_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9e7182087bd3a5ef70bc94d83f3bf87a4a5d0d1885bee7b484a4621c8c1ac65b |
|
MD5 | f5d4f79ac66ad9f1bddc88ba03ae8000 |
|
BLAKE2b-256 | 7fe4f6150b9be35302a151b7af23ebee97a888a4ca21916f94f8da349a47c2b9 |
Hashes for nostr_sdk-0.32.1-cp39-cp39-manylinux_2_28_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b773eba28d60fea8164ba1269c87ba3a50951e04f0fc80f01095d31011d40ed5 |
|
MD5 | 051d95caead15c30d3763d47c5d9ec1a |
|
BLAKE2b-256 | 8f1c5a3d436c2863c3567ddbc4dfa52a07f5f7f14a88de37a2fb13078abd9976 |
Hashes for nostr_sdk-0.32.1-cp39-cp39-macosx_11_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c243d50cd0e6644cd6ad058ac700822369ce1986b1a27d274cbe32e61ac9e5b4 |
|
MD5 | 4737681f3a74834f76940d51854ceafe |
|
BLAKE2b-256 | 5c336fdb0579b6913113425da8673e5af3e80aacc820ab5a55b21f1c656a4e48 |
Hashes for nostr_sdk-0.32.1-cp39-cp39-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cf9cdbedf91df2818b64d03051c6c765df8099ad3c7bb7529cae3a9903f53b23 |
|
MD5 | 3657834ef42893865a16fecad9c0d1ff |
|
BLAKE2b-256 | a6babc8efab7791d09911019fd620d14d5216ec2cfe8dcdcef8e900f41254e83 |