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, EventSource, init_logger, LogLevel
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_relay("wss://relay.damus.io")
await client.add_relay("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()])
source = EventSource.relays(timedelta(seconds=10))
events = await client.get_events_of([f], source)
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
File details
Details for the file nostr_sdk-0.35.0-cp312-cp312-win_amd64.whl
.
File metadata
- Download URL: nostr_sdk-0.35.0-cp312-cp312-win_amd64.whl
- Upload date:
- Size: 8.3 MB
- Tags: CPython 3.12, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 88b617e05bd29f0b097fbcf8c5c6dac7a78dd40bbd4c37385392858db2a9a6ec |
|
MD5 | 1acf6425fdca68b9c4be46647e10a2c6 |
|
BLAKE2b-256 | 43e98fb0483da686eb059f8a6ad16726e5cc424702985518f5c682705efbcf32 |
File details
Details for the file nostr_sdk-0.35.0-cp312-cp312-manylinux_2_31_aarch64.whl
.
File metadata
- Download URL: nostr_sdk-0.35.0-cp312-cp312-manylinux_2_31_aarch64.whl
- Upload date:
- Size: 9.6 MB
- Tags: CPython 3.12, manylinux: glibc 2.31+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ac6eec6e5f2923ccb6acb6c2e6d5a9c2551c9ff4609d4764a7c25c35a22a71d2 |
|
MD5 | e6ca7a68afa171878573961a5b779843 |
|
BLAKE2b-256 | 48b165a10527c8bcdbcf0d2a3070e159932f391b7c0b95d7b93ca90d77ddfc37 |
File details
Details for the file nostr_sdk-0.35.0-cp312-cp312-manylinux_2_28_x86_64.whl
.
File metadata
- Download URL: nostr_sdk-0.35.0-cp312-cp312-manylinux_2_28_x86_64.whl
- Upload date:
- Size: 9.6 MB
- Tags: CPython 3.12, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9c6da952ffe38b2a306781021d6a5352a107b779dcc3d8bddae5de6fa0cce93d |
|
MD5 | 735390bb7221a0df4ce8907ae64b129f |
|
BLAKE2b-256 | b2b48dbc2744a5ba41f45431ab524741d149118600be43417568fc15a8d10b21 |
File details
Details for the file nostr_sdk-0.35.0-cp312-cp312-macosx_11_0_x86_64.whl
.
File metadata
- Download URL: nostr_sdk-0.35.0-cp312-cp312-macosx_11_0_x86_64.whl
- Upload date:
- Size: 9.2 MB
- Tags: CPython 3.12, macOS 11.0+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 77782d9ceade968ccf299b54ada021d7a7acd4f87084ed6ea3a8358885a1087e |
|
MD5 | 927b7ef57c97660a8f9590a5301c5ac5 |
|
BLAKE2b-256 | 422f784befc42a960a80d47db2684bf3c5735791049697dd5046eb870971ce56 |
File details
Details for the file nostr_sdk-0.35.0-cp312-cp312-macosx_11_0_arm64.whl
.
File metadata
- Download URL: nostr_sdk-0.35.0-cp312-cp312-macosx_11_0_arm64.whl
- Upload date:
- Size: 8.7 MB
- Tags: CPython 3.12, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | bcc0758eaeef124df8f4df33efaef7af7ed18011ac7bd9165d7399734eb7fe0e |
|
MD5 | 4aea7ee49b1cae13c5474b6d8b7e4141 |
|
BLAKE2b-256 | e1c2620cfe3e85e074c9de45e7fa887e68ff079784ab7d3325ce6a727cfed987 |
File details
Details for the file nostr_sdk-0.35.0-cp311-cp311-win_amd64.whl
.
File metadata
- Download URL: nostr_sdk-0.35.0-cp311-cp311-win_amd64.whl
- Upload date:
- Size: 8.3 MB
- Tags: CPython 3.11, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8e3c6dcbb2d5fb794e0b463a199d2e41b7de063ad6cdf8b3dfa195bfbbdb85ca |
|
MD5 | 55dce693dfd749fef40b4e2c6fd6c56c |
|
BLAKE2b-256 | 8b78da84219fc09a50e0b5b381f099784b2432fd6d2f1a77741eef6c750549da |
File details
Details for the file nostr_sdk-0.35.0-cp311-cp311-manylinux_2_31_aarch64.whl
.
File metadata
- Download URL: nostr_sdk-0.35.0-cp311-cp311-manylinux_2_31_aarch64.whl
- Upload date:
- Size: 9.6 MB
- Tags: CPython 3.11, manylinux: glibc 2.31+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | cba0b7caec8f2e4f0cb264519a596a59772e9e7aea5cd2576608c006a26b213c |
|
MD5 | dcf1a830279a15e5498c9199e01c0871 |
|
BLAKE2b-256 | dcc38c0d2bdb31ac8eb1ed3936a118ae1581348e799336c06ca1f2ecd9ca9ac5 |
File details
Details for the file nostr_sdk-0.35.0-cp311-cp311-manylinux_2_28_x86_64.whl
.
File metadata
- Download URL: nostr_sdk-0.35.0-cp311-cp311-manylinux_2_28_x86_64.whl
- Upload date:
- Size: 9.6 MB
- Tags: CPython 3.11, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 263d5fce7fd4f52c6a2d4cc4991c0ba9a59d0d7835c23d9e02ff7c9d3fa32015 |
|
MD5 | 9a1c34876d7af778bc332b16cea02946 |
|
BLAKE2b-256 | a1f8606a1e8f71ae3a043b0652ce514df24f661aca3332f1f63bee43b8eb738e |
File details
Details for the file nostr_sdk-0.35.0-cp311-cp311-macosx_11_0_x86_64.whl
.
File metadata
- Download URL: nostr_sdk-0.35.0-cp311-cp311-macosx_11_0_x86_64.whl
- Upload date:
- Size: 9.2 MB
- Tags: CPython 3.11, macOS 11.0+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d53c7c2656be18828cd4c522ee0521239110972ea73f27bf670e7b108d4a309f |
|
MD5 | 0b94a4a79c853e30e99d31f8d647199e |
|
BLAKE2b-256 | 0ccf1b93ea29af83d0a64720b938bbf127f5f6d60e16e536e16062970e34638d |
File details
Details for the file nostr_sdk-0.35.0-cp311-cp311-macosx_11_0_arm64.whl
.
File metadata
- Download URL: nostr_sdk-0.35.0-cp311-cp311-macosx_11_0_arm64.whl
- Upload date:
- Size: 8.7 MB
- Tags: CPython 3.11, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a889c92b113bf176abcc2db4cb6e9d5fd9681b7e8d9df9704ea1321652058416 |
|
MD5 | 164010a5cfe7cd15c92935998b310350 |
|
BLAKE2b-256 | b24a41d38e170d5812a968ca3dee2faf21c42c0bb1723f92701f0493bc8ceff6 |
File details
Details for the file nostr_sdk-0.35.0-cp310-cp310-win_amd64.whl
.
File metadata
- Download URL: nostr_sdk-0.35.0-cp310-cp310-win_amd64.whl
- Upload date:
- Size: 8.3 MB
- Tags: CPython 3.10, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 17800ec9940b7d9a367384846ad710e777e670eb9dd6603488f921749fd83c69 |
|
MD5 | 11d8331e7023f69701fbce533c03205a |
|
BLAKE2b-256 | e83de07fdc5e9c451bec2293985352a35fa2826c15287496d5f9329c4fe8b25f |
File details
Details for the file nostr_sdk-0.35.0-cp310-cp310-manylinux_2_31_aarch64.whl
.
File metadata
- Download URL: nostr_sdk-0.35.0-cp310-cp310-manylinux_2_31_aarch64.whl
- Upload date:
- Size: 9.6 MB
- Tags: CPython 3.10, manylinux: glibc 2.31+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 92da12a10a6dc2c1b8c55c29bc6e37173e9b9d6175d9c6d88a2c54673111c8d9 |
|
MD5 | 4502db6af4f81b4f3fa1a58acd480ecd |
|
BLAKE2b-256 | 36f02e706fb6d63b44b0939b7a81b53a3b209bbf5d314ded18e48939bc71a60e |
File details
Details for the file nostr_sdk-0.35.0-cp310-cp310-manylinux_2_28_x86_64.whl
.
File metadata
- Download URL: nostr_sdk-0.35.0-cp310-cp310-manylinux_2_28_x86_64.whl
- Upload date:
- Size: 9.6 MB
- Tags: CPython 3.10, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4ee6c43fc55a553f3c0b2b824732bded600cf9c67e7d7759cb0c67597a2bd800 |
|
MD5 | 3dc817add27be9e7331823a671ab3571 |
|
BLAKE2b-256 | ef65dd336f4071f512226055f609585e27495b21dcf09315e7dc65ca5f35a410 |
File details
Details for the file nostr_sdk-0.35.0-cp310-cp310-macosx_11_0_x86_64.whl
.
File metadata
- Download URL: nostr_sdk-0.35.0-cp310-cp310-macosx_11_0_x86_64.whl
- Upload date:
- Size: 9.2 MB
- Tags: CPython 3.10, macOS 11.0+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c5e06b66e51993dfdf81581eb7f623bc011a186b3d947e433b032e40f2c44bd8 |
|
MD5 | 2aeafe4fe0eef850eb197fce797102c1 |
|
BLAKE2b-256 | 6cb04787bbd7091ac3ce20e8f9aea7b235b41a652735ce1bed9f3ff7d00c8e84 |
File details
Details for the file nostr_sdk-0.35.0-cp310-cp310-macosx_11_0_arm64.whl
.
File metadata
- Download URL: nostr_sdk-0.35.0-cp310-cp310-macosx_11_0_arm64.whl
- Upload date:
- Size: 8.7 MB
- Tags: CPython 3.10, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 06e672a39e0fd9cedb6a18015d2c3c4fe1286ee14df545739bf9917d375f979c |
|
MD5 | 20c134d2412603ab8f87b0ede1c5ae88 |
|
BLAKE2b-256 | ea97c969e09a60ba9b0a0121c5998e3a95d2c1a535c2af0ef862896e03c0e741 |
File details
Details for the file nostr_sdk-0.35.0-cp39-cp39-win_amd64.whl
.
File metadata
- Download URL: nostr_sdk-0.35.0-cp39-cp39-win_amd64.whl
- Upload date:
- Size: 8.3 MB
- Tags: CPython 3.9, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a9ffc30f31f48f5f03c90f2a47beb4eb3e37c39d3aa6e668bcda915a5b70908b |
|
MD5 | e1941f77551a1b452394bb352f35cde8 |
|
BLAKE2b-256 | 3f1d989c967d8bf5220893a082fdcd166e8f3f23046a7e9eb792063a140ba1f3 |
File details
Details for the file nostr_sdk-0.35.0-cp39-cp39-manylinux_2_31_aarch64.whl
.
File metadata
- Download URL: nostr_sdk-0.35.0-cp39-cp39-manylinux_2_31_aarch64.whl
- Upload date:
- Size: 9.6 MB
- Tags: CPython 3.9, manylinux: glibc 2.31+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e2a7307f5684e410563d9c8e56bcef20bb0499960dd2df01329dd538221730e5 |
|
MD5 | c5fa4b0ba3eaa113bd50901e95521c8a |
|
BLAKE2b-256 | aeac0bea566b867f49d36b6c3209589ceebb7bcf37fec758429c8b5a0d6ae87b |
File details
Details for the file nostr_sdk-0.35.0-cp39-cp39-manylinux_2_28_x86_64.whl
.
File metadata
- Download URL: nostr_sdk-0.35.0-cp39-cp39-manylinux_2_28_x86_64.whl
- Upload date:
- Size: 9.6 MB
- Tags: CPython 3.9, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a0f469571f6598d81edfbbf8931a83207ac673377b5034d78460ea73801e90a6 |
|
MD5 | d3dc783edd7242f3bcc25de489d85fe3 |
|
BLAKE2b-256 | 2b2aef65581f36f5e8c22b23a1da36e691b3a77aac8e0f1b06394ae7929078c8 |
File details
Details for the file nostr_sdk-0.35.0-cp39-cp39-macosx_11_0_x86_64.whl
.
File metadata
- Download URL: nostr_sdk-0.35.0-cp39-cp39-macosx_11_0_x86_64.whl
- Upload date:
- Size: 9.2 MB
- Tags: CPython 3.9, macOS 11.0+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 651c1a408a55d39fc70983d5a60e1c8c43d9565b945b05dc7529b1b1352594d3 |
|
MD5 | cb290adc61a16b26617918b1852ac309 |
|
BLAKE2b-256 | e640b3edebf36b704f452b06f8628dc07760e6eeebefbd6ef058f793206c7302 |
File details
Details for the file nostr_sdk-0.35.0-cp39-cp39-macosx_11_0_arm64.whl
.
File metadata
- Download URL: nostr_sdk-0.35.0-cp39-cp39-macosx_11_0_arm64.whl
- Upload date:
- Size: 8.7 MB
- Tags: CPython 3.9, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6b269bb01dc9c8d9d19307366c82e38c9e0c8ac423dde0d192fd3967afc3cbe9 |
|
MD5 | 0907eb891db50dfb597fd7a6033ce11a |
|
BLAKE2b-256 | 19622a006d3b65a7e46e0ec086160042b0ab0fc81277f75a22e9f1430693df4b |