### Run a Grasp Server Source: https://github.com/fiatjaf/nak/blob/master/README.md Starts a local relay with Grasp protocol support. ```shell ~> nak serve --grasp ``` -------------------------------- ### Enable Verbose Debugging for Nak Source: https://github.com/fiatjaf/nak/blob/master/README.md This shows how to install Nak with the `debug` tag to enable verbose output for all messages sent and received to relays, and then provides an example of using `nak req` with this debugging enabled. ```shell ~> go install -tags=debug github.com/fiatjaf/nak@latest ~> # ~> # then, for example: ~> nak req -k 30617 -k 30618 pyramid.treegaze.com gitnostr.com -a bbb5dda0e15567979f0543407bdc2033d6f0bbb30f72512a981cfdb2f09e2747 ``` ```shell pyramid.treegaze.com... ok. gitnostr.com... ok. [nl][debug] 2025/12/05 22:00:53 {wss://gitnostr.com} sending '["REQ","1:nak-req",{"kinds":[30617,30618],"authors":["bbb5dda0e15567979f0543407bdc2033d6f0bbb30f72512a981cfdb2f09e2747"]}]' [nl][debug] 2025/12/05 22:00:53 {wss://pyramid.treegaze.com} sending '["REQ","2:nak-req",{"kinds":[30617,30618],"authors":["bbb5dda0e15567979f0543407bdc2033d6f0bbb30f72512a981cfdb2f09e2747"]}]' ``` -------------------------------- ### Install nak with curl Source: https://github.com/fiatjaf/nak/blob/master/README.md Installs the nak tool using a one-liner curl command. Ensure you have curl and a shell environment to execute this command. ```sh curl -sSL https://raw.githubusercontent.com/fiatjaf/nak/master/install.sh | sh ``` -------------------------------- ### Run a Blossom Server Source: https://github.com/fiatjaf/nak/blob/master/README.md Starts a local relay with Blossom protocol support. ```shell ~> nak serve --blossom ``` -------------------------------- ### Gift-wrap and Publish Event Source: https://github.com/fiatjaf/nak/blob/master/README.md This example shows how to create an event, gift-wrap it with a secret key for a recipient's public key, and then publish the wrapped event to a relay. ```shell ~> nak event -c 'secret message' | nak gift wrap --sec -p | nak event wss://dmrelay.com ``` -------------------------------- ### Start a Local Bunker Source: https://github.com/fiatjaf/nak/blob/master/README.md This command starts a local Nostr bunker instance, connecting to specified relays. You will be prompted for your secret key's password. The output includes the bunker's URI for client connections. ```shell nak bunker --sec ncryptsec1qggrp80ptf0s7kyl0r38ktzg60fem85m89uz7um6rjn4pnep2nnvcgqm8h7q36c76z9sypatdh4fmw6etfxu99mv5cxkw4ymcsryw0zz7evyuplsgvnj5yysf449lq94klzvnahsw2lzxflvcq4qpf5q -k 3fbf7fbb2a2111e205f74aca0166e29e421729c9a07bc45aa85d39535b47c9ed relay.damus.io nos.lol relay.nsecbunker.com connecting to relay.damus.io... ok. connecting to nos.lol... ok. connecting to relay.nsecbunker.com... ok. type the password to decrypt your secret key: *** listening at [wss://relay.damus.io wss://nos.lol wss://relay.nsecbunker.com]: pubkey: f59911b561c37c90b01e9e5c2557307380835c83399756f4d62d8167227e420a npub: npub17kv3rdtpcd7fpvq7newz24eswwqgxhyr8xt4daxk9kqkwgn7gg9q4gy8vf authorized keys: - 3fbf7fbb2a2111e205f74aca0166e29e421729c9a07bc45aa85d39535b47c9ed to restart: nak bunker --sec ncryptsec1qggrp80ptf0s7kyl0r38ktzg60fem85m89uz7um6rjn4pnep2nnvcgqm8h7q36c76z9sypatdh4fmw6etfxu99mv5cxkw4ymcsryw0zz7evyuplsgvnj5yysf449lq94klzvnahsw2lzxflvcq4qpf5q -k 3fbf7fbb2a2111e205f74aca0166e29e421729c9a07bc45aa85d39535b47c9ed relay.damus.io nos.lol relay.nsecbunker.com bunker: bunker://f59911b561c37c90b01e9e5c2557307380835c83399756f4d62d8167227e420a?relay=wss%3A%2F%2Frelay.damus.io&relay=wss%3A%2F%2Fnos.lol&relay=wss%3A%2F%2Frelay.nsecbunker.com&secret=XuuiMbcLwuwL ``` -------------------------------- ### Start a Persistent Bunker Source: https://github.com/fiatjaf/nak/blob/master/README.md Use the `--persist` flag to start a bunker that saves its metadata (secret key, relays, authorized client pubkeys) to disk. This allows for easier restarts without re-entering all parameters. ```shell ~> nak bunker --persist --sec ncryptsec1... relay.nsec.app nos.lol ``` ```shell ~> nak bunker --persist ``` ```shell ~> nak bunker --profile myself ... ``` -------------------------------- ### Mount Nostr as FUSE Filesystem and Publish Note Source: https://github.com/fiatjaf/nak/blob/master/README.md This example demonstrates mounting Nostr as a FUSE filesystem using `nak fs` and then publishing a note by writing to a file and touching `publish`. ```shell ~> nak fs --sec 01 ~/nostr - mounting at /home/user/nostr... ok. ~> cd ~/nostr/npub1xxxxxx/notes/ ~> echo "satellites are bad!" > new pending note updated, timer reset. - `touch publish` to publish immediately - `rm new` to erase and cancel the publication. ~> touch publish publishing now! {"id":"f1cbfa6...","pubkey":"...","content":"satellites are bad!","sig":"..."} publishing to 3 relays... offchain.pub: ok, nostr.wine: ok, pyramid.fiatjaf.com: ok event published as f1cbfa6... and updated locally. ``` -------------------------------- ### Enable Negentropy Support Source: https://github.com/fiatjaf/nak/blob/master/README.md Starts a local relay with Negentropy (NIP-77) support enabled for managing event history. ```shell ~> nak serve --negentropy ``` -------------------------------- ### Run a Verbose Local Relay Source: https://github.com/fiatjaf/nak/blob/master/README.md Starts a local Nostr relay with verbose logging to observe requests and events. ```shell ~> nak serve > relay running at ws://localhost:10547 got request {"kinds":[1],"authors":["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"],"since":1724082362} got event {"kind":1,"id":"e3c6bf630d6deea74c0ee2f7f7ba6da55a627498a32f1e72029229bb1810bce3","pubkey":"79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","created_at":1724082366,"tags":[],"content":"two","sig":"34261cf226c3fee2df24e55a89f43f5349c98a64bce46bdc46807b0329f334cea93e9e8bc285c1259a5684cf23f5e507c8e6dad47a31a6615d706b1130d09e69"} got event {"kind":1,"id":"0bbb397c8f87ae557650b9d6ee847292df8e530c458ffea1b24bdcb7bed0ec5e","pubkey":"79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","created_at":1724082369,"tags":[],"content":"three","sig":"aa1cb7d5f0f03f358fc4c0a4351a4f1c66e3a7627021b618601c56ba598b825b6d95d9c8720a4c60666a7eb21e17018cf326222f9f574a9396f2f2da7f007546"} • events stored: 2, subscriptions opened: 1 got event {"kind":1,"id":"029ebff759dd54dbd01b929f879fea5802de297e1c3768ca16d9b97cc8bca38f","pubkey":"79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","created_at":1724082371,"tags":[],"content":"four","sig":"9816de517d87d4c3ede57c1c50e3c237486794241afadcd891e1acbba2c5e672286090e6ad3402b047d69bae8095bc4e20e57ac70d92386dfa26db216379330f"} got event {"kind":1,"id":"fe6489fa6fbb925be839377b9b7049d73be755dc2bdad97ff6dd9eecbf8b3a32","pubkey":"79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","created_at":1724082383,"tags":[],"content":"five","sig":"865ce5e32eead5bdb950ac1fbc55bc92dde26818ee3136634538ec42914de179a51e672c2d4269d4362176e5e8cd5e08e69b35b91c6c2af867e129b93d607635"} got request {"kinds":[30818]} • events stored: 4, subscriptions opened: 1 ``` -------------------------------- ### Publish Formed Event with Tags and Relays Source: https://github.com/fiatjaf/nak/blob/master/README.md This example shows how to publish a fully formed Nostr event using `nak publish`, including adding hashtags, converting identifiers to URIs, and specifying read/write relays. ```shell echo "#surely you're joking, mr npub1l2vyh47mk2p0qlsku7hg0vn29faehy9hy34ygaclpn66ukqp3afqutajft olas.app is broken again" | nak publish # it will add the hashtag, turn the npub1 code into a nostr:npub1 URI, turn the olas.app string into https://olas.app, add the "p" tag (and "q" tags too if you were mentioning an nevent1 code or naddr1 code) and finally publish it to your "write" relays and to any mentioned person (or author of mentioned events)'s "read" relays. # there is also a --reply flag that you can pass an nevent, naddr or hex id to and it will do the right thing (including setting the correct kind to either 1 or 1111). # and there is a --confirm flag that gives you a chance to confirm before actually publishing the result to relays. ``` -------------------------------- ### Get description and details for a Nostr event kind Source: https://github.com/fiatjaf/nak/blob/master/README.md Use the 'nak kind' command to retrieve the description for a given event kind number or name. It can also fetch detailed JSON information for specific kinds. ```shell ~> nak kind 10050 | jq .description ``` ```shell ~> nak kind 'fav relays' | jq ``` -------------------------------- ### Verify an Event with Nak CLI Source: https://github.com/fiatjaf/nak/blob/master/README.md This snippet demonstrates how to pipe a JSON event into the 'nak verify' command to check for validity. It shows an example of an invalid event due to an incorrect ID. ```shell ~> echo '{"content":"hello world","created_at":1698923350,"id":"05bd99d54cb835f327e0092c4275ee44c7ff51219eff417c19f70c9e2c53ad5a","kind":1,"pubkey":"79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","sig":"0a04a296321ed933858577f36fb2fb9a0933e966f9ee32b539493f5a4d00120891b1ca9152ebfbc04fb403bdaa7c73f415e7c4954e55726b4b4fa8cebf008cd6","tags":[]}' | nak verify invalid .id, expected 05bd99d54cb835f427e0092c4275ee44c7ff51219eff417c19f70c9e2c53ad5a, got 05bd99d54cb835f327e0092c4275ee44c7ff51219eff417c19f70c9e2c53ad5a ``` -------------------------------- ### Generate NIP-70 Protected Event Source: https://github.com/fiatjaf/nak/blob/master/README.md Create a NIP-70 protected event with a specified timestamp and multi-value tags. The example demonstrates setting the timestamp to 'two weeks ago' and includes complex 'e' and 'p' tags. ```shell ~> nak event --ts 'two weeks ago' -t '-' -t 'e=f59911b561c37c90b01e9e5c2557307380835c83399756f4d62d8167227e420a;wss://relay.whatever.com;root;a9e0f110f636f3191644110c19a33448daf09d7cda9708a769e91b7e91340208' -t 'p=a9e0f110f636f3191644110c19a33448daf09d7cda9708a769e91b7e91340208;wss://p-relay.com' -c 'I know the future' {"kind":1,"id":"f030fccd90c783858dfcee204af94826cf0f1c85d6fc85a0087e9e5172419393","pubkey":"79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","created_at":1719677535,"tags":[["-"],["e","f59911b561c37c90b01e9e5c2557307380835c83399756f4d62d8167227e420a","wss://relay.whatever.com","root","a9e0f110f636f3191644110c19a33448daf09d7cda9708a769e91b7e91340208"],["p","a9e0f110f636f3191644110c19a33448daf09d7cda9708a769e91b7e91340208","wss://p-relay.com"]],"content":"I know the future","sig":"8b36a74e29df8bc12bed66896820da6940d4d9409721b3ed2e910c838833a178cb45fd5bb1c6eb6adc66ab2808bfac9f6644a2c55a6570bb2ad90f221c9c7551"} ``` -------------------------------- ### Get a public key from a private key Source: https://github.com/fiatjaf/nak/blob/master/README.md Derives the public key associated with a given private key. This is useful for verifying ownership or for use in Nostr protocols. ```shell ~> nak key public 7b94e287b1fafa694ded1619b27de7effd3646104a158e187ff4edc56bc6148d 985d66d2644dfa7676e26046914470d66ebc7fa783a3f57f139fde32d0d631d7 ``` -------------------------------- ### Upload and Download Files with Blossom Source: https://github.com/fiatjaf/nak/blob/master/README.md Demonstrates uploading a file using `nak blossom upload` and downloading a file using `nak blossom download`, specifying the server and file identifiers. ```shell ~> nak blossom --server blossom.azzamo.net --sec 01 upload image.png {"sha256":"38c51756f3e9fedf039488a1f6e513286f6743194e7a7f25effdc84a0ee4c2cf","url":"https://blossom.azzamo.net/38c51756f3e9fedf039488a1f6e513286f6743194e7a7f25effdc84a0ee4c2cf.png"} ~> nak blossom --server aegis.utxo.one download acc8ea43d4e6b706f68b249144364f446854b7f63ba1927371831c05dcf0256c -o downloaded.png ``` -------------------------------- ### Manage NIP-34/GRASS Git repositories Source: https://github.com/fiatjaf/nak/blob/master/README.md A set of commands for managing Git repositories compatible with NIP-34/GRASS. Includes cloning, initialization, status checks, and synchronization operations. ```shell ~> nak git clone ``` ```shell ~> nak git init ``` ```shell ~> nak git status ``` ```shell ~> nak git sync ``` ```shell ~> nak git fetch ``` ```shell ~> nak git pull ``` ```shell ~> nak git push ``` -------------------------------- ### Record and Publish Audio Note from Bunker Source: https://github.com/fiatjaf/nak/blob/master/README.md This snippet demonstrates recording an audio note using `ffmpeg`, uploading it via `nak blossom`, converting the URL to JSON, and then publishing it as a 'voice message' event signed from a bunker. ```shell ffmpeg -f alsa -i default -f webm -t 00:00:03 pipe:1 | nak blossom --server blossom.primal.net upload | jq -rc '{content: .url}' | nak event -k 'voice message' --sec 'bunker://urlgoeshere' pyramid.fiatjaf.com nostr.wine ``` -------------------------------- ### List NIP-60 Wallet Tokens and Send/Pay Source: https://github.com/fiatjaf/nak/blob/master/README.md This snippet shows how to list available NIP-60 wallet tokens using `nak wallet tokens`, send a token with `nak wallet send`, and pay an invoice with `nak wallet pay`. ```shell ~> nak wallet tokens 91a10b6fc8bbe7ef2ad9ad0142871d80468b697716d9d2820902db304ff1165e 500 cashu.space cac7f89f0611021984d92a7daca219e4cd1c9798950e50e952bba7cde1ac1337 1000 legend.lnbits.com ~> nak wallet send 100 cashuA1psxqyry8... ~> nak wallet pay lnbc1... ``` -------------------------------- ### Generate a new random key and display public key Source: https://github.com/fiatjaf/nak/blob/master/README.md Generates a new random private key and simultaneously displays its corresponding public key in both nsec and npub formats. Requires the 'pee' utility for concurrent output processing. ```shell ~> nak key generate | pee 'nak encode nsec' 'nak key public | nak encode npub' 1a851afaa70a26faa82c5b4422ce967c07e278efc56a1413b9719b662f86551a 8031621a54b2502f5bd4dbb87c971c0a69675d252a64d69e22224f3aee6dd2b2 ``` -------------------------------- ### Download NIP-35 Torrent from nevent Source: https://github.com/fiatjaf/nak/blob/master/README.md This snippet shows how to download a NIP-35 torrent using `aria2c` by fetching the `nevent` data with `nak` and parsing it with `jq` to construct a magnet link. ```shell ~> # this requires the jq utils from two steps above ~> aria2c $(nak fetch nevent1qqsdsg6x7uujekac4ga7k7qa9q9sx8gqj7xzjf5w9us0dm0ghvf4ugspp4mhxue69uhkummn9ekx7mq6dw9y4 | jq -r '"magnet:?xt=urn:btih:"+(tag_value("x"))+"&dn="+(tag_value("title"))+"&tr=http%3A%2F%2Ftracker.loadpeers.org%3A8080%2FxvRKfvAlnfuf5EfxTT5T0KIVPtbqAHnX%2Fannounce&tr=udp%3A%2F%2Ftracker.coppersurfer.tk%3A6969%2Fannounce&tr=udp%3A%2F%2Ftracker.openbittorrent.com%3A6969%2Fannounce&tr=udp%3A%2F%2Fopen.stealth.si%3A80%2Fannounce&tr=udp%3A%2F%2Ftracker.torrent.eu.org%3A451%2Fannounce&tr=udp%3A%2F%2Ftracker.opentrackr.org%3A1337&tr="+(tags("tracker") | map(.[1] | @uri) | join("&tr="))') ``` -------------------------------- ### Connect Client URI to Bunker Source: https://github.com/fiatjaf/nak/blob/master/README.md Send a `nostrconnect://` client URI to a running bunker using the `connect` subcommand. If using a persisted profile, specify the profile name with `--profile`. ```shell ~> nak bunker connect 'nostrconnect://...' ``` ```shell ~> nak bunker connect --profile default 'nostrconnect://...' ``` -------------------------------- ### Create Event Signed with Environment Variable Key Source: https://github.com/fiatjaf/nak/blob/master/README.md Creates a Nostr event signed with a private key provided via the NOSTR_SECRET_KEY environment variable. Requires password input for encrypted keys. ```shell ~> export NOSTR_SECRET_KEY=ncryptsec1qggyy9vw0nclmw8ly9caz6aa7f85a4ufhsct64uva337pulsdw00n6twa2lzhzk2znzsyu60urx9s08lx00ke6ual3lszyn5an9zarm6s70lw5lj6dv3mj3f9p4tvp0we6qyz4gp420mapfmvqheuttv ~> nak event -c 'it supports keys as hex, nsec or ncryptsec' type the password to decrypt your secret key: ******** ``` ```json {"kind":1,"id":"5cbf3feb9a7d99c3ee2a88693a591caca1a8348fea427b3652c27f7a8a76af48","pubkey":"b00bcab55375d8c7b731dd9841f6d805ff1cf6fdc945e7326786deb5ddac6ce4","created_at":1724247924,"tags":[],"content":"it supports keys as hex, nsec or ncryptsec","sig":"fb3fd170bc10e5042322c7a05dd4bbd8ac9947b39026b8a7afd1ee02524e8e3aa1d9554e9c7b6181ca1b45cab01cd06643bdffa5ce678b475e6b185e1c14b085"} ``` -------------------------------- ### Download and Unwrap Gift-wrap Event Source: https://github.com/fiatjaf/nak/blob/master/README.md This snippet demonstrates how to download a gift-wrapped event from a relay using `nak req`, and then unwrap it using `nak gift unwrap` with the sender's public key and your secret key. ```shell ~> nak req -p -k 'giftwrap' relay.com | nak gift unwrap --sec --from ``` -------------------------------- ### Allow Pubkey on Relay's NIP-86 API Source: https://github.com/fiatjaf/nak/blob/master/README.md Use this command to allow a specific public key to interact with a relay's NIP-86 management API. You will be prompted to enter the password for your secret key. ```shell nak admin allowpubkey --sec ncryptsec1qggx54cg270zy9y8krwmfz29jyypsuxken2fkk99gr52qhje968n6mwkrfstqaqhq9eq94pnzl4nff437l4lp4ur2cs4f9um8738s35l2esx2tas48thtfhrk5kq94pf9j2tpk54yuermra0xu6hl5ls --pubkey a9e0f110f636f3191644110c19a33448daf09d7cda9708a769e91b7e91340208 pyramid.fiatjaf.com type the password to decrypt your secret key: ********** calling 'allowpubkey' on https://pyramid.fiatjaf.com... { "result": null, "error": "failed to add to whitelist: pubkey 985d66d2644dfa7676e26046914470d66ebc7fa783a3f57f139fde32d0d631d7 doesn't have permission to invite" } ``` -------------------------------- ### Paginate Event Downloads from Relay Source: https://github.com/fiatjaf/nak/blob/master/README.md Download a large number of events from a relay by using the `--paginate` and `--paginate-interval` flags to make sequential requests, bypassing natural query limits. The output is saved to a JSONL file. ```shell ~> nak req -k 1 --limit 50000 --paginate --paginate-interval 2s nos.lol > events.jsonl ~> wc -l events.jsonl 50000 events.jsonl ``` -------------------------------- ### Watch NIP-53 Livestream using jq Utils Source: https://github.com/fiatjaf/nak/blob/master/README.md Fetches NIP-53 livestream information and pipes it to mpv player using jq utilities to extract the streaming URL. ```shell ~> # this requires the jq utils from the step above ~> mpv $(nak fetch naddr1qqjxvvm9xscnsdtx95cxvcfk956rsvtx943rje3k95mx2dp389jnwwrp8ymxgqg4waehxw309aex2mrp0yhxgctdw4eju6t09upzpn6956apxcad0mfp8grcuugdysg44eepex68h50t73zcathmfs49qvzqqqrkvu7ed38k | jq -r 'tag_value("streaming")') ~> ``` -------------------------------- ### Filter events from a file by kind and pubkey Source: https://github.com/fiatjaf/nak/blob/master/README.md Use the 'nak filter' command to select events from a JSONL file based on their kind and author's public key. The output is redirected to a new file. ```shell ~> cat all.jsonl | nak filter -k 1111 -a 117673e191b10fe1aedf1736ee74de4cffd4c132ca701960b70a5abad5870faa > filtered.jsonl ``` -------------------------------- ### Create and publish a custom Nostr event Source: https://github.com/fiatjaf/nak/blob/master/README.md Creates a Nostr event with custom content and tags, signed with a specified private key, and published to multiple relays. Ensure the private key is valid and relays are accessible. ```shell ~> nak event --sec 02 -c 'good morning' --tag t=gm nostr-pub.wellorder.net relay.damus.io {"id":"e20978737ab7cd36eca300a65f11738176123f2e0c23054544b18fe493e2aa1a","pubkey":"c6047f9441ed7d6d3045406e95c07cd85c778e4b8cef3ca7abac09b95c709ee5","created_at":1698632753,"kind":1,"tags":[["t","gm"]],"content":"good morning","sig":"5687c1a97066c349cb3bde0c0719fd1652a13403ba6aca7557b646307ee6718528cd86989db08bf6a7fd04bea0b0b87c1dd1b78c2d21b80b80eebab7f40b8916"} publishing to wss://nostr-pub.wellorder.net... success. publishing to wss://relay.damus.io... success. ``` -------------------------------- ### Display Bunker QR Code Source: https://github.com/fiatjaf/nak/blob/master/README.md Add the `--qrcode` flag to the `nak bunker` command to display a QR code of the bunker URI, facilitating easy connection from mobile clients. ```shell nak bunker --qrcode --sec ncryptsec1... relay.damus.io ``` -------------------------------- ### Generate a private key Source: https://github.com/fiatjaf/nak/blob/master/README.md Generates a new private key for Nostr. This key should be kept secret. ```shell ~> nak key generate 7b94e287b1fafa694ded1619b27de7effd3646104a158e187ff4edc56bc6148d ``` -------------------------------- ### Create Event with Proof-of-Work Target Source: https://github.com/fiatjaf/nak/blob/master/README.md Generates a Nostr event with a specified content and a Proof-of-Work target. The output includes the event's JSON representation with the calculated nonce and target. ```shell ~> nak event -c 'hello getwired.app and labour.fiatjaf.com' --pow 24 ``` ```json {"kind":1,"id":"0000009dcc7c62056eafdb41fac817379ec2becf0ce27c5fbe98d0735d968147","pubkey":"79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","created_at":1724160828,"tags":[["nonce","515504","24"]],"content":"hello getwired.app and labour.fiatjaf.com","sig":"7edb988065ccc12779fe99270945b212f3723838f315d76d5e90e9ffa27198f13fa556614295f518d968d55bab81878167d4162b3a7cf81a6b423c6761bd504c"} ``` -------------------------------- ### Watch NIP-53 Livestream without jq Utils Source: https://github.com/fiatjaf/nak/blob/master/README.md Fetches NIP-53 livestream information and pipes it to mpv player by directly parsing the tags to extract the streaming URL. ```shell ~> # or without the utils ~> mpv $(nak fetch naddr1qqjxvvm9xscnsdtx95cxvcfk956rsvtx943rje3k95mx2dp389jnwwrp8ymxgqg4waehxw309aex2mrp0yhxgctdw4eju6t09upzpn6956apxcad0mfp8grcuugdysg44eepex68h50t73zcathmfs49qvzqqqrkvu7ed38k | jq -r '.tags | map(select(.[0] == "streaming") | .[1])[0]') ``` -------------------------------- ### Sign an event collaboratively with multiple parties using MUSIG2 Source: https://github.com/fiatjaf/nak/blob/master/README.md Initiates a multi-party MUSIG2 signing process for a Nostr event. The first step generates a nonce secret that must be securely shared for subsequent steps. ```shell ~> nak event --sec 1234 -k 'text note' -c 'hello from a combined key' --musig 2 the following code should be saved secretly until the next step an included with --musig-nonce-secret: QebOT03ERmV7km22CqEqBPFmzAkgxQzGGbR7Si8yIZCBrd1N9A3LKwGLO71kbgXZ9EYFKpjiwun4u0mj5Tq6vwM3pK7x+EI8oHbkt9majKv/QN24Ix8qnwEIHxXX+mXBug== the next signer and they should call this on their side: nak event --sec --musig 2 -k 1 -ts 1720821287 -c 'hello from a combined key' --musig-pubkey 0337a4aef1f8423ca076e4b7d99a8cabff40ddb8231f2a9f01081f15d7fa65c1ba --musig-nonce 0285af37c6c43638cda2c773098e867c749ddf1e9d096b78686c5d000603935ad3025c4a1e042eb6b0dcfd864d1e072d2ce8da06f2c0dcf13fd7d1fcef0dd26dbc92 ``` -------------------------------- ### Download jq Functions for Nostr Events Source: https://github.com/fiatjaf/nak/blob/master/README.md Fetches Nostr event data from a relay and saves helpful jq functions to ~/.jq for processing events. ```shell ~> nak req -i 412f2d3e73acc312942c055ac2a695dc60bf58ff97e06689a8a79e97796c4cdb relay.westernbtc.com | jq -r .content > ~/.jq ``` -------------------------------- ### Create a default Nostr event Source: https://github.com/fiatjaf/nak/blob/master/README.md Generates a signed Nostr event of kind 1 using the default key. The output is a JSON object representing the signed event. ```shell ~> nak event {"id":"53443506e7d09e55b922a2369b80f926007a8a8a8ea5f09df1db59fe1993335e","pubkey":"79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","created_at":1698632644,"kind":1,"tags":[],"content":"hello from the nostr army knife","sig":"4bdb609c975b2b61338c2ff4c7ce91d4afe74bea4ed1601a62e1fd125bd4c0ae6e0166cca96e5cfb7e0f50583eb6a0dd0b66072566299b6007742db56278010c"} ``` -------------------------------- ### Sign an event using a bunker provider Source: https://github.com/fiatjaf/nak/blob/master/README.md Signs a Nostr event using a specified bunker provider. It's recommended to set the NOSTR_CLIENT_KEY environment variable permanently for consistent identity. ```shell ~> export NOSTR_CLIENT_KEY="$(nak key generate)" ~> nak event --sec 'bunker://a9e0f110f636f3191644110c19a33448daf09d7cda9708a769e91b7e91340208?relay=wss%3A%2F%2Frelay.damus.io&relay=wss%3A%2F%2Frelay.nsecbunker.com&relay=wss%3A%2F%2Fnos.lol&secret=TWfGbjQCLxUf' -c 'hello from bunker' ``` -------------------------------- ### Fetch Last 10 Quoted Events by Pubkey in 2023 Source: https://github.com/fiatjaf/nak/blob/master/README.md This command fetches the last 10 notes from a specific pubkey in 2023, extracts quoted Nostr event IDs, decodes them, and then queries for those events. ```shell ~> nak req -l 10 -k 1 --until 'December 31 2023' -a 2edbcea694d164629854a52583458fd6d965b161e3c48b57d3aff01940558884 relay.damus.io | jq -r '.content | match("nostr:((note1|nevent1)[a-z0-9]+)";"g") | .captures[0].string' | nak decode | jq -cr '{ids: [.id]}' | nak req relay.damus.io ``` -------------------------------- ### Fetch and pretty-print a Nostr event Source: https://github.com/fiatjaf/nak/blob/master/README.md Fetches a Nostr event using a NIP-19 'nevent1' code, automatically resolving relay and author hints. The fetched event is then pretty-printed using 'jq'. ```shell nak fetch nevent1qqs2e3k48vtrkzjm8vvyzcmsmkf58unrxtq2k4h5yspay6vhcqm4wqcpz9mhxue69uhkummnw3ezuamfdejj7q3ql2vyh47mk2p0qlsku7hg0vn29faehy9hy34ygaclpn66ukqp3afqxpqqqqqqz7ttjyq | jq { "id": "acc6d53b163b0a5b3b18416370dd9343f26332c0ab56f42403d26997c0375703", "pubkey": "fa984bd7dbb282f07e16e7ae87b26a2a7b9b90b7246a44771f0cf5ae58018f52", "created_at": 1697370933, "kind": 1, "tags": [], "content": "`q` tags = a kind 1 that wanted to be a kind:6 but fell short\n\n🥁", "sig": "b5b63d7c8491a4a0517df2c58151665c583abc6cd31fd50b957bf8fefc8e55c87c922cbdcb50888cb9f1c03c26ab5c02c1dccc14b46b78e1e16c60094f2358da" } ``` -------------------------------- ### Format Event with jq for Readability Source: https://github.com/fiatjaf/nak/blob/master/README.md Transforms Nostr events by adding a human-readable datetime and removing sensitive fields like signature and creation time. ```shell ~> nak req -k 1 -l 5 relay.damus.io --jq '. + { d: datetime } | del(.sig, .created_at)' ``` -------------------------------- ### Interact with NIP-29 groups Source: https://github.com/fiatjaf/nak/blob/master/README.md Commands for managing and interacting with NIP-29 groups. Includes fetching group information, managing administrators, and sending messages within a group chat. ```shell ~> nak group info "'" ``` ```shell ~> nak group admin "'" ``` ```shell ~> nak group chat "'" ``` ```shell ~> nak group chat send "'" "" ``` -------------------------------- ### Query relay for event IDs using Negentropy Source: https://github.com/fiatjaf/nak/blob/master/README.md Fetch only the IDs of events matching a specific query from a relay using Negentropy. This is useful for efficiently retrieving event identifiers. ```shell ~> nak req --ids-only -k 1111 -a npub1vyrx2prp0mne8pczrcvv38ahn5wahsl8hlceeu3f3aqyvmu8zh5s7kfy55 relay.damus.io ``` -------------------------------- ### Fetch missing events using negentropy sync Source: https://github.com/fiatjaf/nak/blob/master/README.md Fetches Nostr events from a relay, excluding those present in a local JSON Lines file. This is useful for synchronizing event databases efficiently. ```shell ~> nak req --only-missing ./events.jsonl -k 30617 pyramid.fiatjaf.com ``` -------------------------------- ### Sync Events Between Two Relays Source: https://github.com/fiatjaf/nak/blob/master/README.md This command uses `nak sync` to synchronize events between two specified relays. ```shell ~> nak sync relay1.com relay2.com ``` -------------------------------- ### Sign an event using a NIP-49 encrypted key Source: https://github.com/fiatjaf/nak/blob/master/README.md Signs a Nostr event using a private key that is encrypted with NIP-49. The command prompts for the password to decrypt the key before signing. ```shell ~> nak event --sec ncryptsec1qggx54cg270zy9y8krwmfz29jyypsuxken2fkk99gr52qhje968n6mwkrfstqaqhq9eq94pnzl4nff437l4lp4ur2cs4f9um8738s35l2esx2tas48thtfhrk5kq94pf9j2tpk54yuermra0xu6hl5ls -c 'hello from encrypted key' type the password to decrypt your secret key: ********** {"kind":1,"id":"8aa5c931fb1da507f14801de6a1814b7f0baae984dc502b9889f347f5aa3cc4e","pubkey":"985d66d2644dfa7676e26046914470d66ebc7fa783a3f57f139fde32d0d631d7","created_at":1720822280,"tags":[],"content":"hello from encrypted key","sig":"9d1c9e56e87f787cc5b6191ec47690ce59fa4bef105b56297484253953e18fb930f6683f007e84a9ce9dc9a25b20c191c510629156dcd24bd16e15d302d20944"} ``` -------------------------------- ### Query relays for events with specific tags Source: https://github.com/fiatjaf/nak/blob/master/README.md Queries multiple relays for Nostr events matching a specific tag ('t=gm') with a limit of 2 events per relay. The output is filtered using 'jq' to display only the content of the events. ```shell ~> nak req -k 1 -t t=gm -l 2 nostr.mom nostr.wine nostr-pub.wellorder.net | jq .content "#GM, you sovereign savage #freeple of the #nostrverse. Let's cause some #nostroversy. " "ITM slaves!\n#gm https://image.nostr.build/cbbcdf80bfc302a6678ecf9387c87d87deca3e0e288a12e262926c34feb3f6aa.jpg " "good morning" "The problem is to start, but along the way it's fixed #GM ☀️" "Activando modo zen…\n\n#GM #Nostr #Hispano" ``` -------------------------------- ### Display profile information for a Nostr key Source: https://github.com/fiatjaf/nak/blob/master/README.md Retrieves and displays detailed profile information for a given Nostr identifier (npub, NIP-05, or hex key). Includes fields like name, about, picture, and relays. ```shell ~> nak profile f7z.io pubkey (hex): fa984bd7dbb282f07e16e7ae87b26a2a7b9b90b7246a44771f0cf5ae58018f52 npub: npub1l2vyh47mk2p0qlsku7hg0vn29faehy9hy34ygaclpn66ukqp3afqutajft profile uri: nostr:nprofile1qqs04xzt6ldm9qhs0ctw0t58kf4z57umjzmjg6jywu0seadwtqqc75spr9mhxue69uhhq7tjv9kkjepwve5kzar2v9nzucm0d5q3qamnwvaz7te3xsczue3h0ghxjmcppemhxue69uhhytnxxaazu6t0axr23s name: PABLOF7z display_name: PABLOF7z about: Magical Other Stuff Maximalist. picture: https://m.primal.net/KwlG.jpg banner: https://24242.io/1dc3a4a8bb2626551d4cc91e93f5b2e6ef87b1931b9db9bf4ac72dfe61c7a45b.png website: https://pablof7z.com nip05: _@f7z.io (verified) lud16: pablof7z@primal.net relays: wss://relay.damus.io (read) wss://relay.primal.net (read) wss://pyramid.fiatjaf.com (write) wss://140.f7z.io (write) wss://r.f7z.io (read/write) follows: 1051 ``` ```shell ~> nak profile f7z.io --name PABLOF7z ```