Skip to main content

CLI tool for handling nostpy events

Project description

nostpy-cli

nostpy-cli is a Command Line Interface tool for sending and querying nostr events by websocket connection.

Features

  • Send events to a specified relays
  • Query events from relays
  • Encode/decode kind4 messages
  • Supports NIP-50 searches

Prerequisites

Before installing nostpy-cli, ensure you have Python 3.6 or higher installed on your system. You can check your Python version by running:

python3 --version

Installation

Install Using pip

To install using pip use the command below:

pip install nostpy-cli

Build from source

Clone the Repository First, clone the repository to your local machine:

git clone https://github.com/UTXOnly/nostpy-cli.git
cd nostpy-cli
python3 -m build
pip install .

Usage

Once installed, you can run nostpy-cli from the command line as shown below:

Send Event

To send an event, you would use a command similar to the following:

nostpy-cli send_event -pubkey "your_public_key_hex" -privkey "your_private_key_hex" -content "your plaintext message" -tags "[['tag1', 'value1']]" -kind 4 --relay "wss://yourrelayurl.com" "wss://yoursecondrelayurl.com"

--pubkey , --priv_key and --relay arguments are required, all else are optional

Example

  • Send a kind 1 event with tags
nostpy-cli send_event -pubkey 5ce5b352f1ef76b1dffc5694dd5b34126137184cc9a7d78cba841c0635e17952 -privkey 2b1e4e1f26517dda57458596760bb3bd3bd3717083763166e12983a6421abc18 -content test27 -tags "[
['t', 'vvfdvfd'], ['v', 'v2']]" -kind 1 --relay wss://relay.nostpy.lol wss://relay.damus.io wss://nos.lol
  • Send a kind 4 direct message
nostpy-cli send_event -pubkey 5ce5b352f1ef76b1dffc5694dd5b34126137184cc9a7d78cba841c0635e17952 -privkey 2b1e4e1f26517dda57458596760bb3bd3bd3717083763166e12983a6421abc18 -content "This is my plaintext message" -tags "[['p', '4503baa127bdfd0b054384dc5ba82cb0e2a8367cbdb0629179f00db1a34caacc']]" -kind 4 --relay wss://relay.nostpy.lol wss://relay.damus.io wss://nos.lol

Query Event

To query events, use the following command:

nostpy-cli query --kinds "[1,9735]" --relay "wss://yourrelayurl.com"

--relay field required

Example

  • Query an event with search
nostpy-cli query -kinds "[31990,1]" -search "random_search" -since 1713629501 -authors npub1g5pm4gf8hh7skp2rsnw9h2pvkr32sdnuhkcx9yte7qxmrg6v4txqqudjqv --relay wss://relay.nostpy.lol

Help

To view all available commands and their options, use the help command:

nostpy-cli -h

Contributing

Contributions to nostpy-cli are welcome! Please feel free to submit pull requests or open issues to report bugs or suggest enhancements.

License

This project is licensed under the MIT 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 Distribution

nostpy_cli-0.2.1.tar.gz (7.3 kB view details)

Uploaded Source

Built Distribution

nostpy_cli-0.2.1-py3-none-any.whl (8.1 kB view details)

Uploaded Python 3

File details

Details for the file nostpy_cli-0.2.1.tar.gz.

File metadata

  • Download URL: nostpy_cli-0.2.1.tar.gz
  • Upload date:
  • Size: 7.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 colorama/0.4.4 importlib-metadata/6.8.0 keyring/23.5.0 pkginfo/1.8.2 readme-renderer/34.0 requests-toolbelt/0.9.1 requests/2.31.0 rfc3986/1.5.0 tqdm/4.57.0 urllib3/1.26.5 CPython/3.10.12

File hashes

Hashes for nostpy_cli-0.2.1.tar.gz
Algorithm Hash digest
SHA256 2e44d5c121766fabb9df27e052f0ab1b55d24042590ffcbec5eba48783c1a093
MD5 af332a0d25d890f431c0916e2792b981
BLAKE2b-256 d35794e1bc84b7a986d4fe1322409496354b8dd6cf36188e8912b207365cd84f

See more details on using hashes here.

File details

Details for the file nostpy_cli-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: nostpy_cli-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 8.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 colorama/0.4.4 importlib-metadata/6.8.0 keyring/23.5.0 pkginfo/1.8.2 readme-renderer/34.0 requests-toolbelt/0.9.1 requests/2.31.0 rfc3986/1.5.0 tqdm/4.57.0 urllib3/1.26.5 CPython/3.10.12

File hashes

Hashes for nostpy_cli-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 7f7645651730165bb55f164f93a9d4f6dac484c6172b0d34e95a8708c2e8019c
MD5 4fe973c73272f035b896fa8cf326610a
BLAKE2b-256 571f52ed2009870254cc341a7e3db95dc2175aa30eabe2b10e8f7668604effe1

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