Python CLI for Nostr
Project description
nostrpy
| CI/CD |
CLI for Nostr
Installation
❯ pip install nostrpy
Usage
Show nostr version
❯ nostr --version
nostr, version 0.6.0
Generate a key pair
❯ nostr key new
{
"Private key": "nsec1w54...edu3",
"Public key": "npub1s92...7ckp"
}
Transform a public key to hex format, or from hex format to public key format
❯ nostr key convert -i 1a60c40a7...b472
{
"npub": "npub1rfs...c9tg",
"hex": "1a60c40a7...b472"
}
Publish a message
❯ nostr message publish -s <the sender nsec key> -m "Hello, publishing a message through nostr CLI."
{
"Message": "Hello, publishing a message through nostr CLI."
}
Send an encryped direct message
❯ nostr message send -s <the sender nsec key> -m "Hello, sending an encryped direct message" -p <the receiver npub key>
{
"Message": "Hello, sending an encryped direct message"
}
Receive message(s)
❯ nostr message receive -p <the npub key to receive the messages>
{
"Public key": "npub1rfs...c9tg",
"Events": [
"Hello, publishing a message through nostr CLI.",
"Hello, sending an encryped direct message"
],
"Notices": []
}
Simplify the CLI with a config file: config.hcl:
nostr {
relays = [
"wss://nostr-pub.wellorder.net",
"wss://relay.damus.io",
]
self {
name = "Ali Kiten"
nsec = "nsec1jqa...fcjd"
}
receiver "Ray" {
name = "Ray Nostr"
npub = "npub1q75...c62u"
}
listen "jon" {
name = "Jonathon Gate"
npub = "npub1s9c...a9je"
}
listen "jack" {
name = "Jack Hoose"
npub = "npub1s9c...a9je"
}
}
By default, nostr will search the current path config.hcl first, then ${HOME}/.nostr/config.hcl.
You can also manually specify the config file by:
❯ nostr message -c <path/to/the/config.hcl> receive -i jack
Once setting up the config file, the above message commands could be much simpler:
Publish a message with config file
❯ nostr message publish -m "Hello, publishing a message through nostr CLI."
{
"Message": "Hello, publishing a message through nostr CLI."
}
Send an encryped direct message
❯ nostr message send -m "Hello, sending an encryped direct message" -i <the receiver identifier, like "Ray" in the above sample>
{
"Message": "Hello, sending an encryped direct message"
}
Receive message(s)
❯ nostr message receive -i <the listen indentifier in the above sample config file>
{
"Public key": "npub1rfs...c9tg",
"Events": [
"Hello, publishing a message through nostr CLI.",
"Hello, sending an encryped direct message"
],
"Notices": []
}
Development & Test
See the Test Suite README
Feel free to add issues, add PRs, or provide any feedback!
Credits
Repositories:
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file nostrpy-0.6.0.tar.gz.
File metadata
- Download URL: nostrpy-0.6.0.tar.gz
- Upload date:
- Size: 41.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.16
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
15abb2c734f76e1f109b2bfa13c2cf753fc4a663399df6ca989634a41fd5610b
|
|
| MD5 |
fc14ba1ce6b98afdaefdf2fdf2c85c1c
|
|
| BLAKE2b-256 |
106b294ee70650f1aeccfb719bbf9a37dced1126d3102d165c018a9eda7b6860
|
File details
Details for the file nostrpy-0.6.0-py3-none-any.whl.
File metadata
- Download URL: nostrpy-0.6.0-py3-none-any.whl
- Upload date:
- Size: 26.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.16
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f5b5b77d32438c55ffb5103fef1dcf117ad7f245135c773420d45f6256c01379
|
|
| MD5 |
287c71332d9595b91a3958d9fd3e4b3d
|
|
| BLAKE2b-256 |
30f8d6cf0fda946ca30dc64214f2f554e7c1c1d45b3a7b0b7175cbc2e6304ae0
|