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.32.2-cp312-cp312-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c92399bc27932bbf49a743c06cbe30249fdc6482b7214411e7b162ef5e8bc7c2 |
|
MD5 | 7335f2f5ae9561b0c551555bef3dd14b |
|
BLAKE2b-256 | 7b715e1a79ec2e800bc0254f3606736b552954aba1f17a4eed65335eae19fd4c |
Hashes for nostr_sdk-0.32.2-cp312-cp312-manylinux_2_31_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b9cecef3eaa545fcd56dd015b9d1e587384b8b4a8023f77c0af2a51ec5d0e9d4 |
|
MD5 | 1b0e80eec20306401405363682ed9fec |
|
BLAKE2b-256 | 75f1b7e464c873a67c0a38ad53512934a205550f46328a6efc2f103378e80c15 |
Hashes for nostr_sdk-0.32.2-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8df0bf4158101823093c86b6e8216ded6f839eca8a92a55c9db306457a3e6d64 |
|
MD5 | 370ade9f57ed590e1ab578117894c3cd |
|
BLAKE2b-256 | b528b41493bc495a0f1a0a603158bcad4715edbf9f48cd084512e37588035852 |
Hashes for nostr_sdk-0.32.2-cp312-cp312-macosx_11_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b997bb77f9a7471a0250ad1e0d30c177ca9889266b75fb164de2f803fd47f715 |
|
MD5 | bb84b52f6b4d531020d22d73e661ef7a |
|
BLAKE2b-256 | 3bb1eec830b3cc0376c9984a94a6ebf58ee2eb2f28b7c6b2e36bac0d94e7722d |
Hashes for nostr_sdk-0.32.2-cp312-cp312-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c9730037d53d1a4ff8cedec2397ea7f733c65e3c7ba1f1f4be3b74a77bbca09b |
|
MD5 | e6a63c81efed0033c9dd3e0efcd845d0 |
|
BLAKE2b-256 | 09a2435e8cf666a3c92ebdb96897edf4f3dc805587a8f4b631c9c749b4360f02 |
Hashes for nostr_sdk-0.32.2-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 866c596de8d183750068843b716af909b3ca0924b48023110b99bc7e233cec42 |
|
MD5 | eb3787bb396118ec28474daad5364d8a |
|
BLAKE2b-256 | 7c0c9966c8a603144f1d2b4044d9f9d38a36a5aa4aef9aa387f07c86b75c3a1e |
Hashes for nostr_sdk-0.32.2-cp311-cp311-manylinux_2_31_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 819002590e1003bd1d40f483078380fdac655201259236de88525f8778a81eb9 |
|
MD5 | 2e240e009bca7c968a606241422c7c7c |
|
BLAKE2b-256 | 877d7a05826ff1b249d063b84754586042f58f86a026bcf2789af7154b678b26 |
Hashes for nostr_sdk-0.32.2-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 30b855a2b6e17b9cd0a390095efe0337c3520a85f67543d42c8175e3b002a07e |
|
MD5 | c86e7f07df41384337e503947b276007 |
|
BLAKE2b-256 | 7c0798e42a1c2b626713c41290bc1805f12a385cea3697020086039166df53a4 |
Hashes for nostr_sdk-0.32.2-cp311-cp311-macosx_11_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f5ff2514641f287bb8b0bd6742836ea9dfc04a4e2617ba98d3f0efb2e29787d0 |
|
MD5 | 9c3caca13d1e64257b72ecfc56a42ba4 |
|
BLAKE2b-256 | 443abcf2b696606d3c8d7c55b6fbadc412a296b8421f2693bcb2b61abd195f4c |
Hashes for nostr_sdk-0.32.2-cp311-cp311-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b1fd2633217d217b897664c42f923547edc6ef08fea722892c45770ed847a467 |
|
MD5 | 7cb7d022013032b008912e41377cd700 |
|
BLAKE2b-256 | cc9827a49a60715af795508679e829182c6bc4adc8a541bd5c8943f5d1f282d8 |
Hashes for nostr_sdk-0.32.2-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a3887f5d6a2560614e548f0423adc9fde32a538dc019d86ea3a994a7bbd30823 |
|
MD5 | 8a676898ac3abc7f045010e67ca116bf |
|
BLAKE2b-256 | 5fbcafae3fa7e772aec02c8f6e52a968e555dcd3c111f46fcacc253da37f16ab |
Hashes for nostr_sdk-0.32.2-cp310-cp310-manylinux_2_31_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e643515443dcf45424d5effb6f604a9a2321fa896fff0f32197ede88feeb2bdc |
|
MD5 | e81bd61319942e4e711cde458cf68e66 |
|
BLAKE2b-256 | 1183a77bd058c35c3aa493052f7ae631a6baf5ea7affbc9bd11ade0b90610e98 |
Hashes for nostr_sdk-0.32.2-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bbd01246b1732ab0b5c0fd3de3a95a23cd68309029687382ac75168f2de12d3e |
|
MD5 | b42301335c7bf2b54858dbc59cf7dc29 |
|
BLAKE2b-256 | 5640cefd13110346bb6f24f32903ed93a5091242189800c02b464c24db852c5d |
Hashes for nostr_sdk-0.32.2-cp310-cp310-macosx_11_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2c98d2df76937b58003ce1372efadcf1769552bbae7b64960b8bfc3f452b31e3 |
|
MD5 | ba2da3295569fc00bb923d18d2ed93de |
|
BLAKE2b-256 | b747efbfcdc7ec948a766383fdaef40741b5ab48725b653ea52156a5315b4764 |
Hashes for nostr_sdk-0.32.2-cp310-cp310-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a65343c30adf1f4cb5bd250c1e30e03af9791ed618e68d34f0932d083f200abb |
|
MD5 | e0e35b824a04920bd6eb4e414dfa557a |
|
BLAKE2b-256 | a94a4eff541a19d51ba226cea23b964baea271dc6a7537821ad08bc55a45fd12 |
Hashes for nostr_sdk-0.32.2-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e2d8a9bf6eee1e676bda3b2a6a0ea1a8137ba49de0ef59fe4bf1d90472466649 |
|
MD5 | 401df971c28da7aea2254f250c7f78a6 |
|
BLAKE2b-256 | 35d2a1f811fb092d279c0fb2a6ca7c9a1146955c6b76f54612629776eecf1bfc |
Hashes for nostr_sdk-0.32.2-cp39-cp39-manylinux_2_31_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9bf00f2965031e86a73bad28bfcda08b6bb6859c767b7a0e6899ee81b21efcdc |
|
MD5 | 66e8fb03f5cb3ed15dc341219c8bf711 |
|
BLAKE2b-256 | 433aa74ad0c012ecc9085efb7441ba74f6eeeebbdce32bab5efc9a0b5aa12d35 |
Hashes for nostr_sdk-0.32.2-cp39-cp39-manylinux_2_28_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 762f40f1586d2bddccb4eb4482398aa01422be4d36621c8844c7c7d35dc3d3d2 |
|
MD5 | 6b69cb2d77dd06c42a66689a3e556c44 |
|
BLAKE2b-256 | 4ce14050dbc5b968860fba3f6f88b971de1062073adff74377bfb1f03b6a2eca |
Hashes for nostr_sdk-0.32.2-cp39-cp39-macosx_11_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 79fece85a5a2dabc1f1278d02322f636fd20b35d19c25d43da36fe204803453e |
|
MD5 | b01e65ca61020e8c9d6a43f2eb608c9a |
|
BLAKE2b-256 | e7b46a0c6221f6c666612280fcbd3fb1ff081f4bcfeb506ec56553037c48331f |
Hashes for nostr_sdk-0.32.2-cp39-cp39-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0c0ed607c9df7e54e80deec8be66b6404e41a29ffb377a4a1ea9cf6e7a3b405a |
|
MD5 | c8eb767c2c81478cb6b09fac1cbcb4fe |
|
BLAKE2b-256 | af5b6fa2a093da2470b06e4b21bce74364b21df858ed401f00481ade246bb0d7 |