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_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:

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.35.1-cp312-cp312-win_amd64.whl (8.2 MB view details)

Uploaded CPython 3.12 Windows x86-64

nostr_sdk-0.35.1-cp312-cp312-manylinux_2_31_aarch64.whl (9.6 MB view details)

Uploaded CPython 3.12 manylinux: glibc 2.31+ ARM64

nostr_sdk-0.35.1-cp312-cp312-manylinux_2_28_x86_64.whl (9.6 MB view details)

Uploaded CPython 3.12 manylinux: glibc 2.28+ x86-64

nostr_sdk-0.35.1-cp312-cp312-macosx_11_0_x86_64.whl (9.2 MB view details)

Uploaded CPython 3.12 macOS 11.0+ x86-64

nostr_sdk-0.35.1-cp312-cp312-macosx_11_0_arm64.whl (8.7 MB view details)

Uploaded CPython 3.12 macOS 11.0+ ARM64

nostr_sdk-0.35.1-cp311-cp311-win_amd64.whl (8.2 MB view details)

Uploaded CPython 3.11 Windows x86-64

nostr_sdk-0.35.1-cp311-cp311-manylinux_2_31_aarch64.whl (9.6 MB view details)

Uploaded CPython 3.11 manylinux: glibc 2.31+ ARM64

nostr_sdk-0.35.1-cp311-cp311-manylinux_2_28_x86_64.whl (9.6 MB view details)

Uploaded CPython 3.11 manylinux: glibc 2.28+ x86-64

nostr_sdk-0.35.1-cp311-cp311-macosx_11_0_x86_64.whl (9.2 MB view details)

Uploaded CPython 3.11 macOS 11.0+ x86-64

nostr_sdk-0.35.1-cp311-cp311-macosx_11_0_arm64.whl (8.7 MB view details)

Uploaded CPython 3.11 macOS 11.0+ ARM64

nostr_sdk-0.35.1-cp310-cp310-win_amd64.whl (8.2 MB view details)

Uploaded CPython 3.10 Windows x86-64

nostr_sdk-0.35.1-cp310-cp310-manylinux_2_31_aarch64.whl (9.6 MB view details)

Uploaded CPython 3.10 manylinux: glibc 2.31+ ARM64

nostr_sdk-0.35.1-cp310-cp310-manylinux_2_28_x86_64.whl (9.6 MB view details)

Uploaded CPython 3.10 manylinux: glibc 2.28+ x86-64

nostr_sdk-0.35.1-cp310-cp310-macosx_11_0_x86_64.whl (9.2 MB view details)

Uploaded CPython 3.10 macOS 11.0+ x86-64

nostr_sdk-0.35.1-cp310-cp310-macosx_11_0_arm64.whl (8.7 MB view details)

Uploaded CPython 3.10 macOS 11.0+ ARM64

nostr_sdk-0.35.1-cp39-cp39-win_amd64.whl (8.2 MB view details)

Uploaded CPython 3.9 Windows x86-64

nostr_sdk-0.35.1-cp39-cp39-manylinux_2_31_aarch64.whl (9.6 MB view details)

Uploaded CPython 3.9 manylinux: glibc 2.31+ ARM64

nostr_sdk-0.35.1-cp39-cp39-manylinux_2_28_x86_64.whl (9.6 MB view details)

Uploaded CPython 3.9 manylinux: glibc 2.28+ x86-64

nostr_sdk-0.35.1-cp39-cp39-macosx_11_0_x86_64.whl (9.2 MB view details)

Uploaded CPython 3.9 macOS 11.0+ x86-64

nostr_sdk-0.35.1-cp39-cp39-macosx_11_0_arm64.whl (8.7 MB view details)

Uploaded CPython 3.9 macOS 11.0+ ARM64

File details

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

File metadata

File hashes

Hashes for nostr_sdk-0.35.1-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 6f706fc8d8e7241dada0c84aa51e2536f8e318154b79bb6310547fb8837437c5
MD5 0700efaa74be1f9959259af69bb3b7bf
BLAKE2b-256 6c2ad8f9e11d236b0a1572b95fef72c48acb62d4c9f6b73e009599a083c25b76

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for nostr_sdk-0.35.1-cp312-cp312-manylinux_2_31_aarch64.whl
Algorithm Hash digest
SHA256 89fc8108dba135757f673b019098eb9439e56d3c839b5ce8586a960445073fd7
MD5 dbe9e73754b4cf9721a77252d5a05bec
BLAKE2b-256 2d8ba60e1273a362c89cfacae1e1f465f5ee0ebb827fb67f8de12090b20d8ca9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for nostr_sdk-0.35.1-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 c790248afac69c48d0d5655542224aaa1097a5b05615db58e431ef0dd59c1f6e
MD5 605c1bf3f62124478abce8fc0c67f2cd
BLAKE2b-256 0198211591fd7bc866fe3aea9a8a797216706d107597cf2b348661a559051bc0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for nostr_sdk-0.35.1-cp312-cp312-macosx_11_0_x86_64.whl
Algorithm Hash digest
SHA256 97a6705f007d6ac00b072d0f1e30844b1f76f27addd42e46914de386a1e311dc
MD5 ab0568c2d2297f27036b254f0985fcef
BLAKE2b-256 9f483f61f541959a10ed40c19f6bdc231234e1a1f8ce20b7fbbe77e18b0d257a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for nostr_sdk-0.35.1-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 775f754df1b82872f784dd145ceeed8703e1753c54581e4f98e3886269a67120
MD5 7cc139d5b696de2fc8b0db3a55d814a1
BLAKE2b-256 881752588725f3fb26cdd98594b711c4928374cf042da9da3806becc3f1ff418

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for nostr_sdk-0.35.1-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 c0295b6222354012e81f7fa05f1326e16bdb74c23887e722b463de9b110d30e2
MD5 5916a017b9ef05e059a19a24914f9074
BLAKE2b-256 4b50b2f564a1520b7acbf0277d1c5f25b6da28147685a4052aa70ac455902e6c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for nostr_sdk-0.35.1-cp311-cp311-manylinux_2_31_aarch64.whl
Algorithm Hash digest
SHA256 5b18bbc01c58615ba03ca97beb2e47bf0c433a356099bf9269d835f338d1ed2e
MD5 7860b2bc307579a5a40f941673ac2338
BLAKE2b-256 10705b2359c80737e18928399fa1e1971441a3263de3dfda10572f523080dfdc

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for nostr_sdk-0.35.1-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 2c1bd263177036793fdbaaa528997239368b53b5db57223edf803a0f391841aa
MD5 1643594223ec27660daed41c6ff5f9f9
BLAKE2b-256 d57de53dde6df4909f7d01ab3f1e283547ea00b759b43b6cb154283aeeb072a6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for nostr_sdk-0.35.1-cp311-cp311-macosx_11_0_x86_64.whl
Algorithm Hash digest
SHA256 8f3170f1b5eec01041942a19f80dad2b2c5ce349302ce76fdc91f27730e7010b
MD5 114a8c14358f4e83d53baabdd25f9836
BLAKE2b-256 04c4bfa108ed5e0a45135487ef018d3349aae86680db9b9a43f989dec066a76c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for nostr_sdk-0.35.1-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 bdbbe1832ef2b5aab9ffe4fde4199c68612ac8da7703fb999d5bdfa152ad500e
MD5 68730b9389ba620f37bbd5347d3e00d7
BLAKE2b-256 858a4ab472c0e2d8198b32a27c3307cb16a90528998ae6ad1e83cb5ea1738a81

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for nostr_sdk-0.35.1-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 36f26c48b8cd9977c793f4f487e0f49e0a4dc8fc997d1e7ef0b55b608c709ae4
MD5 ad2da89015b16244b22b6a4cecf9af21
BLAKE2b-256 49fc2c573b14d1a2dc2a70db4709cd8972277540d58e17c12a3de6a58a615e3f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for nostr_sdk-0.35.1-cp310-cp310-manylinux_2_31_aarch64.whl
Algorithm Hash digest
SHA256 f93eea7f6b0bb4549b6470cb97a4c32b91c377bfb9127c9a8c757025cc41e3d8
MD5 3479befc494464b7ad2b136ff83cbc31
BLAKE2b-256 918e68735f6f6bb04d3f761487037baa910174286b857f12b607db0cb26143f5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for nostr_sdk-0.35.1-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 1335ae39ea871a591982b6b34cbfad480858397d7f7c21ec637bedd5acc4a76c
MD5 6b7e6afa68f8ee0a8f84c88f75b8acbe
BLAKE2b-256 0bc860948134fb5e88564c5a4294584767206cb259716bfee72dbf836e2110c3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for nostr_sdk-0.35.1-cp310-cp310-macosx_11_0_x86_64.whl
Algorithm Hash digest
SHA256 f0ad3a92effd80e9e3e4971e670ffd5ca2f757951953e5ad3004d4216b1b7d13
MD5 335dac2e32e5df9052a011d02da2e35d
BLAKE2b-256 d1b3901a35d521d9ac279e141fd5e33e0497aae23efcafe86b4631f82faab61a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for nostr_sdk-0.35.1-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 9cef681701186bd66665d124a8cbeeac1f0899e50e6ea97a7c5c0f257660bf18
MD5 d72a86a6db7423dd14077ffed8800def
BLAKE2b-256 65dc8cd147264cd515fea7f4958c01496cdd8eddf0caf94015358e1b8bee9096

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for nostr_sdk-0.35.1-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 04bc205e7648adfcc737610d4ccc34280fb748b4277d41bb863ba10774bdb5dc
MD5 ccb17ae4c28f2db1ff001167579b4c0f
BLAKE2b-256 bd79199d6e2438efa76185107ffd8fd533cfc3af61403da925a8e2aa93644380

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for nostr_sdk-0.35.1-cp39-cp39-manylinux_2_31_aarch64.whl
Algorithm Hash digest
SHA256 9f30ae16a7fd5b74c9b4ff8784731e1e5a358c1a70929e1e40d20f0330fb7110
MD5 9631fc72575b48299568ad0487cf88f3
BLAKE2b-256 97bb5d0e242513fcac6fc4c0cf0678de4f82a7353ab83d98019ed92812fe3770

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for nostr_sdk-0.35.1-cp39-cp39-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 1e10e4dd2d72b7331baa7bb988deebdc204302d551f3d817e3551710077ed164
MD5 f40ac6dcc2142dc1c111a9f2f98f2d55
BLAKE2b-256 100813e841f94a069815fc7e4d77c3238bbeb98b6f0a760bbdf570d902233c7f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for nostr_sdk-0.35.1-cp39-cp39-macosx_11_0_x86_64.whl
Algorithm Hash digest
SHA256 7d0660e9393473c96c35733decee982262e541a6db9b72c888c347247d4ce9ef
MD5 ab2d828070c1f51e7a6bed2d2a4ae7f2
BLAKE2b-256 2d767a00d6ed1527f2d85c11e115f4d352b202f84d4119e331147e37fdc0a84b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for nostr_sdk-0.35.1-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 c9c338c393747842088998fe2fe4f06446b338b2ede64c6d9917f9e5507db709
MD5 21c952af51e45550c01a3cf5feb5799b
BLAKE2b-256 fa261a5ee0bd10d0f31c382d4ece110767057304654277169012767c00015bb3

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