Skip to main content

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:

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_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()])
    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:

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

nostr_sdk-0.34.0-cp312-cp312-win_amd64.whl (8.1 MB view details)

Uploaded CPython 3.12 Windows x86-64

nostr_sdk-0.34.0-cp312-cp312-manylinux_2_31_aarch64.whl (10.8 MB view details)

Uploaded CPython 3.12 manylinux: glibc 2.31+ ARM64

nostr_sdk-0.34.0-cp312-cp312-manylinux_2_28_x86_64.whl (10.8 MB view details)

Uploaded CPython 3.12 manylinux: glibc 2.28+ x86-64

nostr_sdk-0.34.0-cp312-cp312-macosx_11_0_x86_64.whl (10.3 MB view details)

Uploaded CPython 3.12 macOS 11.0+ x86-64

nostr_sdk-0.34.0-cp312-cp312-macosx_11_0_arm64.whl (9.8 MB view details)

Uploaded CPython 3.12 macOS 11.0+ ARM64

nostr_sdk-0.34.0-cp311-cp311-win_amd64.whl (8.1 MB view details)

Uploaded CPython 3.11 Windows x86-64

nostr_sdk-0.34.0-cp311-cp311-manylinux_2_31_aarch64.whl (10.8 MB view details)

Uploaded CPython 3.11 manylinux: glibc 2.31+ ARM64

nostr_sdk-0.34.0-cp311-cp311-manylinux_2_28_x86_64.whl (10.8 MB view details)

Uploaded CPython 3.11 manylinux: glibc 2.28+ x86-64

nostr_sdk-0.34.0-cp311-cp311-macosx_11_0_x86_64.whl (10.3 MB view details)

Uploaded CPython 3.11 macOS 11.0+ x86-64

nostr_sdk-0.34.0-cp311-cp311-macosx_11_0_arm64.whl (9.8 MB view details)

Uploaded CPython 3.11 macOS 11.0+ ARM64

nostr_sdk-0.34.0-cp310-cp310-win_amd64.whl (8.1 MB view details)

Uploaded CPython 3.10 Windows x86-64

nostr_sdk-0.34.0-cp310-cp310-manylinux_2_31_aarch64.whl (10.8 MB view details)

Uploaded CPython 3.10 manylinux: glibc 2.31+ ARM64

nostr_sdk-0.34.0-cp310-cp310-manylinux_2_28_x86_64.whl (10.8 MB view details)

Uploaded CPython 3.10 manylinux: glibc 2.28+ x86-64

nostr_sdk-0.34.0-cp310-cp310-macosx_11_0_x86_64.whl (10.3 MB view details)

Uploaded CPython 3.10 macOS 11.0+ x86-64

nostr_sdk-0.34.0-cp310-cp310-macosx_11_0_arm64.whl (9.8 MB view details)

Uploaded CPython 3.10 macOS 11.0+ ARM64

nostr_sdk-0.34.0-cp39-cp39-win_amd64.whl (8.1 MB view details)

Uploaded CPython 3.9 Windows x86-64

nostr_sdk-0.34.0-cp39-cp39-manylinux_2_31_aarch64.whl (10.8 MB view details)

Uploaded CPython 3.9 manylinux: glibc 2.31+ ARM64

nostr_sdk-0.34.0-cp39-cp39-manylinux_2_28_x86_64.whl (10.8 MB view details)

Uploaded CPython 3.9 manylinux: glibc 2.28+ x86-64

nostr_sdk-0.34.0-cp39-cp39-macosx_11_0_x86_64.whl (10.3 MB view details)

Uploaded CPython 3.9 macOS 11.0+ x86-64

nostr_sdk-0.34.0-cp39-cp39-macosx_11_0_arm64.whl (9.8 MB view details)

Uploaded CPython 3.9 macOS 11.0+ ARM64

File details

Details for the file nostr_sdk-0.34.0-cp312-cp312-win_amd64.whl.

File metadata

File hashes

Hashes for nostr_sdk-0.34.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 ac81dddfb7c007a202e877a7ff7a88acb5965811222254f6d646180e0faa8d40
MD5 c95d2759461565f49c36f1f757371e28
BLAKE2b-256 e9cfc0a6fcea4dad6edbd98385c2ddf9364b16c8681da2c5cc18ff3505f9e529

See more details on using hashes here.

File details

Details for the file nostr_sdk-0.34.0-cp312-cp312-manylinux_2_31_aarch64.whl.

File metadata

File hashes

Hashes for nostr_sdk-0.34.0-cp312-cp312-manylinux_2_31_aarch64.whl
Algorithm Hash digest
SHA256 410e1a0085f881998a0f5ecc4122782637b58f9b234b18778950a9f4fd279296
MD5 130058dc00bb660313325beb89770b87
BLAKE2b-256 5fd0f3d79c8c0d2848770392ee6b45f9a52ab2c4b37c46d898c8a4a1d1c2d5df

See more details on using hashes here.

File details

Details for the file nostr_sdk-0.34.0-cp312-cp312-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for nostr_sdk-0.34.0-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 c391e4c6b03069a6ed72e3a2580402918111630e4240acfdd8feda604f819d9f
MD5 5eb8642d05afa1d48e445460982d17c9
BLAKE2b-256 f38da82468ae5431b9e2836f9397453243fc0b46da8f061e7376ecbf27fd663c

See more details on using hashes here.

File details

Details for the file nostr_sdk-0.34.0-cp312-cp312-macosx_11_0_x86_64.whl.

File metadata

File hashes

Hashes for nostr_sdk-0.34.0-cp312-cp312-macosx_11_0_x86_64.whl
Algorithm Hash digest
SHA256 a2b7957aac94f3a7df843cb65a82280115381edffbda789a5017295f37e7c783
MD5 fa2a8c4c86cc439e7eb73627927ca11f
BLAKE2b-256 8066eb818f8bc3d322ffa3f6a91e83b04cad3f91fdc2c683e3471c86dd4fea44

See more details on using hashes here.

File details

Details for the file nostr_sdk-0.34.0-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for nostr_sdk-0.34.0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 0116783b690775812139aabc88b76c9e54e62a576bb5f88d58bd7cbaaa440ab0
MD5 6c9c5d231e7940f453504de458d5f4c6
BLAKE2b-256 d8dbf1352cdae28d380cc76474605ef30443c666ef1933eadd864d64bb506e3e

See more details on using hashes here.

File details

Details for the file nostr_sdk-0.34.0-cp311-cp311-win_amd64.whl.

File metadata

File hashes

Hashes for nostr_sdk-0.34.0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 a8ed7fd8fce27cabd312e2a3be93653a11daee4490b7fbe06c160a5ca08b8116
MD5 6697be370b4bc93258870c4c0dc987ad
BLAKE2b-256 b272eb6812dbd7636dd9a827908c53124ad4fd106fed3563bc8c1c3d0a7f48d2

See more details on using hashes here.

File details

Details for the file nostr_sdk-0.34.0-cp311-cp311-manylinux_2_31_aarch64.whl.

File metadata

File hashes

Hashes for nostr_sdk-0.34.0-cp311-cp311-manylinux_2_31_aarch64.whl
Algorithm Hash digest
SHA256 dcbea6183de90f6ec9d20e9a48d5c6e83d3a704edd7a6377d895ec44098adb91
MD5 f807c4643f1af3effa840cd8b301e8e5
BLAKE2b-256 bf4ee6e5afc7271733c249d5ef1f1688d3e181f4d8f3a0d47785152bbabf2209

See more details on using hashes here.

File details

Details for the file nostr_sdk-0.34.0-cp311-cp311-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for nostr_sdk-0.34.0-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 91af0d8647f61a037e09485548ecc69b394b3447cee69d0181556d38f00790d6
MD5 b9844c772c11a3d12158bd8076a49361
BLAKE2b-256 84c174c72b5b90107f5b060864448d3e462af5a84b8290a0dfbd01633e44e6e0

See more details on using hashes here.

File details

Details for the file nostr_sdk-0.34.0-cp311-cp311-macosx_11_0_x86_64.whl.

File metadata

File hashes

Hashes for nostr_sdk-0.34.0-cp311-cp311-macosx_11_0_x86_64.whl
Algorithm Hash digest
SHA256 b56b3943aa0cc779ca765d5d02197c989234b89d78924c81d4cb6f5796defbae
MD5 62420ccf1734b2ba0c4eec18c5fe3e46
BLAKE2b-256 1f44572888921bcbcd0a13868adc5728a681a8e732e78d704eb47ca1103f1157

See more details on using hashes here.

File details

Details for the file nostr_sdk-0.34.0-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for nostr_sdk-0.34.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 5ae70bad7204ba470bf8a8f1c12a58acc55c7a673c5316c6a8e683ac43232781
MD5 c3d3eb5abf24561a5db9d68d51cdd33d
BLAKE2b-256 574620e88fd072c364f70cb2a4341731541f0a64e7495d3b54a6da1fa9d395ec

See more details on using hashes here.

File details

Details for the file nostr_sdk-0.34.0-cp310-cp310-win_amd64.whl.

File metadata

File hashes

Hashes for nostr_sdk-0.34.0-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 9ec6a0ad92c8ed07ebdc264222d64616c0bc02ddb0158696cb20d35948d95af5
MD5 8a1a8c01a2b8c92e13f45ed8828a6ded
BLAKE2b-256 8efa89cb971a638a63c319fd4146dc95a573799432e6e8e51b9c7833db337f5e

See more details on using hashes here.

File details

Details for the file nostr_sdk-0.34.0-cp310-cp310-manylinux_2_31_aarch64.whl.

File metadata

File hashes

Hashes for nostr_sdk-0.34.0-cp310-cp310-manylinux_2_31_aarch64.whl
Algorithm Hash digest
SHA256 ef3e2c9747b5c51c99605b262dde26cdbdb7d0ec35a836c796e11d86173f3e55
MD5 7c7b5903dae3b89d2116f86771fed1c3
BLAKE2b-256 4b35849674e3af4e636c2ee4d72048e722a21999792d1664ce5cabc8e65bf320

See more details on using hashes here.

File details

Details for the file nostr_sdk-0.34.0-cp310-cp310-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for nostr_sdk-0.34.0-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 2aa82981ee66b72c815905931f428aeb878b6de632bf4bf25b807548eb90b30d
MD5 f3af655114105c91b171e1365f052394
BLAKE2b-256 b51442845a897bfe02488c531942b447716e5c5fcbc628c059d81d361506b620

See more details on using hashes here.

File details

Details for the file nostr_sdk-0.34.0-cp310-cp310-macosx_11_0_x86_64.whl.

File metadata

File hashes

Hashes for nostr_sdk-0.34.0-cp310-cp310-macosx_11_0_x86_64.whl
Algorithm Hash digest
SHA256 a025aa53263c53f2b06fd33e8977f9fcf5ec49b61790459c99b44dc160568205
MD5 d3962f63c9a79201e2af6f61671e0ce2
BLAKE2b-256 2f7fd0b1051d23b75aa4a74cd7db2a7f197480ed0e0aed2b54bb8e4db8fd5f72

See more details on using hashes here.

File details

Details for the file nostr_sdk-0.34.0-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for nostr_sdk-0.34.0-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e893fe85d6c4504c0416258399ccac76e0611bd8c55212d68ff3084b7eb4f105
MD5 b6114cab5c65189ccb3d48f427d5ca4c
BLAKE2b-256 d2b36357d85defe9796386f38c3ff12a37f969d31a4f9779878320b65ed15734

See more details on using hashes here.

File details

Details for the file nostr_sdk-0.34.0-cp39-cp39-win_amd64.whl.

File metadata

File hashes

Hashes for nostr_sdk-0.34.0-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 3222120dad607e6c0e7b081db6f8ed72749aef5994158b53750090f72e53c637
MD5 54f440e4e3856cb83678bdd1a4b19d7c
BLAKE2b-256 754807aac1c37f389e846a52b8c788fb8c1d8cc3d09874589609c931ecfd6c9c

See more details on using hashes here.

File details

Details for the file nostr_sdk-0.34.0-cp39-cp39-manylinux_2_31_aarch64.whl.

File metadata

File hashes

Hashes for nostr_sdk-0.34.0-cp39-cp39-manylinux_2_31_aarch64.whl
Algorithm Hash digest
SHA256 7f0de104914c86c3671b538fe17060581d7f7fcc9360f5cc2792bda043be1e40
MD5 a7a2366116916920ddb9b5fef3f7764a
BLAKE2b-256 1792d6ad9174f0162ca6f41e824dbbabb0fa49b3c44bd0a2a08daaa8db7b841c

See more details on using hashes here.

File details

Details for the file nostr_sdk-0.34.0-cp39-cp39-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for nostr_sdk-0.34.0-cp39-cp39-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 542d390307dfe643d2b80aa6dfc48e6d2d12df8131aa6229649225505d50a675
MD5 f728b4f233d1bc9d746ac0649c0dce93
BLAKE2b-256 e839270a664b3dd43dc772c932ed11f38df22d48c11d21af79c1e36e896a0c69

See more details on using hashes here.

File details

Details for the file nostr_sdk-0.34.0-cp39-cp39-macosx_11_0_x86_64.whl.

File metadata

File hashes

Hashes for nostr_sdk-0.34.0-cp39-cp39-macosx_11_0_x86_64.whl
Algorithm Hash digest
SHA256 26427eadc55f2e88eab1db5098fff4f034f6ec78dcabc0360a7ab09941c501b6
MD5 47545f132a3af69c9410db3ef200f9d8
BLAKE2b-256 b7a81cab8191fae81a961c103db22fff2b702cf92a5b6aabe27d3b1a2dc9c068

See more details on using hashes here.

File details

Details for the file nostr_sdk-0.34.0-cp39-cp39-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for nostr_sdk-0.34.0-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 747b00f751962d1ce20d1e29be6c9ed4860843ae49411a28aaf710ff317de0d1
MD5 ac9a3c642af90d331dc82fbf1681422f
BLAKE2b-256 de3541db5d20b3b4ade37a69863cec864faf1454a83e7d57065d4706b0219fb5

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page