{"id":13832712,"url":"https://github.com/0xtlt/nostr_rust","last_synced_at":"2025-08-20T04:33:00.579Z","repository":{"id":62748932,"uuid":"561492314","full_name":"0xtlt/nostr_rust","owner":"0xtlt","description":"Functional Rust implementation of the nostr protocol","archived":false,"fork":false,"pushed_at":"2023-02-15T16:30:29.000Z","size":123,"stargazers_count":58,"open_issues_count":4,"forks_count":16,"subscribers_count":4,"default_branch":"main","last_synced_at":"2024-12-15T16:57:32.840Z","etag":null,"topics":["nostr","rust"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/0xtlt.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2022-11-03T20:10:58.000Z","updated_at":"2024-08-25T18:38:09.000Z","dependencies_parsed_at":"2024-01-13T16:28:41.426Z","dependency_job_id":"513b85c6-2bcd-4dc2-bece-7084cd89dfd5","html_url":"https://github.com/0xtlt/nostr_rust","commit_stats":{"total_commits":98,"total_committers":3,"mean_commits":"32.666666666666664","dds":"0.12244897959183676","last_synced_commit":"b8a9ab72c0f46627ceec37f2ca5a763d55626a89"},"previous_names":[],"tags_count":32,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/0xtlt%2Fnostr_rust","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/0xtlt%2Fnostr_rust/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/0xtlt%2Fnostr_rust/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/0xtlt%2Fnostr_rust/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/0xtlt","download_url":"https://codeload.github.com/0xtlt/nostr_rust/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":230394228,"owners_count":18218707,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["nostr","rust"],"created_at":"2024-08-04T11:00:28.538Z","updated_at":"2024-12-19T07:07:17.727Z","avatar_url":"https://github.com/0xtlt.png","language":"Rust","funding_links":[],"categories":["Install from Source","Libraries"],"sub_categories":["Nostr","Client reviews and/or comparisons"],"readme":"# nostr_rust\n\n[![crates.io](https://img.shields.io/crates/v/nostr_rust.svg)](https://crates.io/crates/nostr_rust)\n[![Documentation](https://docs.rs/nostr_rust/badge.svg)](https://docs.rs/nostr_rust)\n[![MIT/Apache-2 licensed](https://img.shields.io/crates/l/nostr_rust.svg)](./LICENSE.txt)\n[![CI](https://github.com/0xtlt/nostr_rust/actions/workflows/ci.yml/badge.svg)](https://github.com/0xtlt/nostr_rust/actions/workflows/ci.yml)\n[![Issues](https://img.shields.io/github/issues/0xtlt/nostr_rust)](https://img.shields.io/github/issues/0xtlt/nostr_rust)\n\nAn ergonomic, [Nostr](https://github.com/nostr-protocol/nostr) API Client for Rust.\n\n- [Changelog](CHANGELOG.md)\n\n## Example\n\n```toml\n[dependencies]\nnostr_rust = \"*\"\n```\n\nAnd then the code:\n\n```rust,norun\nuse std::{\n    str::FromStr,\n    sync::{Arc, Mutex},\n    thread,\n};\n\nuse nostr_rust::{nostr_client::Client, req::ReqFilter, Identity, Message, events::extract_events_ws, utils::parse_content_tags};\n\nfn handle_message(relay_url: \u0026String, message: \u0026Message) -\u003e Result\u003c(), String\u003e {\n    println!(\"Received message from {}: {:?}\", relay_url, message);\n\n    let events = extract_events_ws(message);\n    println!(\"Events: {:?}\", events);\n\n    Ok(())\n}\n\nfn main() {\n    let my_identity =\n        Identity::from_str(\"your private key as hex string\")\n            .unwrap();\n\n    let nostr_client = Arc::new(Mutex::new(\n        Client::new(vec![\"wss://relay.nostr.info\"]).unwrap(),\n    ));\n\n    // Run a new thread to handle messages\n    let nostr_clone = nostr_client.clone();\n    let handle_thread = thread::spawn(move || {\n        println!(\"Listening...\");\n        let events = nostr_clone.lock().unwrap().next_data().unwrap();\n\n        for (relay_url, message) in events.iter() {\n            handle_message(relay_url, message).unwrap();\n        }\n    });\n\n    // Change metadata\n    nostr_client\n        .lock()\n        .unwrap()\n        .set_metadata(\n            \u0026my_identity,\n            Some(\"Rust Nostr Client test account\"),\n            Some(\"Hello Nostr! #5\"),\n            None,\n            None,\n            0,\n        )\n        .unwrap();\n\n    // Subscribe to my last text note\n    let subscription_id = nostr_client\n        .lock()\n        .unwrap()\n        .subscribe(vec![ReqFilter {\n            ids: None,\n            authors: Some(vec![\n                \"884704bd421721e292edbff42eb77547fe115c6ff9825b08fc366be4cd69e9f6\".to_string(),\n            ]),\n            kinds: None,\n            e: None,\n            p: None,\n            since: None,\n            until: None,\n            limit: Some(1),\n        }])\n        .unwrap();\n\n    // Unsubscribe\n    nostr_client\n        .lock()\n        .unwrap()\n        .unsubscribe(\u0026subscription_id)\n        .unwrap();\n\n    // You can use the parse content tags method to get the content and the tags from a string\n    // let tags = parse_content_tags(\"hello #world\", vec![], Some(nostr_rust::DEFAULT_HASHTAG), true, true);\n    // assert_eq!(tags.content, \"hello #world\");\n    //  assert_eq!(tags.tags, vec![vec![\"t\", \"world\"]]);\n\n    // Publish a text note\n    nostr_client\n        .lock()\n        .unwrap()\n        .publish_text_note(\u0026my_identity, \"Hello Nostr! :)\", \u0026[], 0)\n        .unwrap();\n\n    // Publish a proof of work text note with a difficulty target of 15\n    nostr_client\n        .lock()\n        .unwrap()\n        .publish_text_note(\u0026my_identity, \"Hello Nostr! :)\", \u0026[], 15)\n        .unwrap();\n\n    // Wait for the thread to finish\n    handle_thread.join().unwrap();\n}\n\n## Async feature\n\nIf you want to use the async version of the client, you can enable the `async` feature:\n\n```toml\n[dependencies]\nnostr_rust = { version = \"*\", features = [\"async\"] }\n```\n\n## NIPs Supported\n\n| NIP                                                            | Supported     | Client Version | Description                                                  |\n| -------------------------------------------------------------- | ------------- | -------------- | ------------------------------------------------------------ |\n| [01](https://github.com/nostr-protocol/nips/blob/master/01.md) | ✅            | 0.1.0          | Basic protocol flow description                              |\n| [02](https://github.com/nostr-protocol/nips/blob/master/02.md) | ✅            | 0.3.0          | Contact List and Petnames                                    |\n| [03](https://github.com/nostr-protocol/nips/blob/master/03.md) | ❌            | Not supported  | OpenTimestamps Attestations for Events                       |\n| [04](https://github.com/nostr-protocol/nips/blob/master/04.md) | ✅            | 0.6.0          | Encrypted Direct Message                                     |\n| [05](https://github.com/nostr-protocol/nips/blob/master/05.md) | ✅            | 0.15.0  | Mapping Nostr keys to DNS-based internet identifiers         |\n| [06](https://github.com/nostr-protocol/nips/blob/master/06.md) | ❌            | Not supported  | Basic key derivation from mnemonic seed phrase               |\n| [07](https://github.com/nostr-protocol/nips/blob/master/07.md) | Not concerned | Not supported  | window.nostr capability for web browsers                     |\n| [08](https://github.com/nostr-protocol/nips/blob/master/08.md) | Not concerned            | Not supported  | Handling Mentions                                            |\n| [09](https://github.com/nostr-protocol/nips/blob/master/09.md) | ✅            | 0.5.0          | Event Deletion                                               |\n| [10](https://github.com/nostr-protocol/nips/blob/master/10.md) | Not concerned            | Not supported  | Conventions for clients' use of e and p tags in text events. |\n| [11](https://github.com/nostr-protocol/nips/blob/master/11.md) | ✅            | 0.9.0          | Relay Information Document                                   |\n| [12](https://github.com/nostr-protocol/nips/blob/master/12.md) | ❌            | Not supported  | Generic Tag Queries                                          |\n| [13](https://github.com/nostr-protocol/nips/blob/master/13.md) | ✅            | 0.8.0          | Proof of Work                                                |\n| [14](https://github.com/nostr-protocol/nips/blob/master/14.md) | Not concerned            | Not supported  | Subject tag in text events.                                  |\n| [15](https://github.com/nostr-protocol/nips/blob/master/15.md) | ❌            | Not supported  | End of Stored Events Notice                                  |\n| [16](https://github.com/nostr-protocol/nips/blob/master/16.md) | ✅            | 0.13.0         | Event Treatment                                              |\n| [22](https://github.com/nostr-protocol/nips/blob/master/22.md) | ❌            | Not supported  | Event created_at Limits                                      |\n| [25](https://github.com/nostr-protocol/nips/blob/master/25.md) | ✅            | 0.4.0          | Reactions                                                    |\n| [28](https://github.com/nostr-protocol/nips/blob/master/28.md) | ❌            | Not supported  | Public Chat                                                  |\n\n## License\n\nLicensed under MIT license ([LICENSE-MIT](LICENSE-MIT) or \u003chttp://opensource.org/licenses/MIT\u003e)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F0xtlt%2Fnostr_rust","html_url":"https://awesome.ecosyste.ms/projects/github.com%2F0xtlt%2Fnostr_rust","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F0xtlt%2Fnostr_rust/lists"}