{"id":27950994,"url":"https://github.com/block-core/nostr-client","last_synced_at":"2026-03-07T03:03:51.976Z","repository":{"id":283280502,"uuid":"950842418","full_name":"block-core/nostr-client","owner":"block-core","description":null,"archived":false,"fork":false,"pushed_at":"2026-01-27T15:40:14.000Z","size":132073,"stargazers_count":1,"open_issues_count":2,"forks_count":0,"subscribers_count":4,"default_branch":"master","last_synced_at":"2026-01-28T02:16:56.647Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://block-core.github.io/nostr-client/","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/block-core.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":"AGENTS.md","dco":null,"cla":null}},"created_at":"2025-03-18T19:07:08.000Z","updated_at":"2026-01-27T15:38:58.000Z","dependencies_parsed_at":"2025-05-07T16:16:36.530Z","dependency_job_id":"72d00676-9e53-436a-972c-b12fe056cfa4","html_url":"https://github.com/block-core/nostr-client","commit_stats":null,"previous_names":["block-core/nostr-client"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/block-core/nostr-client","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/block-core%2Fnostr-client","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/block-core%2Fnostr-client/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/block-core%2Fnostr-client/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/block-core%2Fnostr-client/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/block-core","download_url":"https://codeload.github.com/block-core/nostr-client/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/block-core%2Fnostr-client/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30206341,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-06T19:07:06.838Z","status":"online","status_checked_at":"2026-03-07T02:00:06.765Z","response_time":53,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":[],"created_at":"2025-05-07T16:16:33.291Z","updated_at":"2026-03-07T03:03:51.957Z","avatar_url":"https://github.com/block-core.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"![Logo](https://raw.githubusercontent.com/Marfusios/nostr-client/master/nostr.png)\n# Nostr client \n[![.NET Core](https://github.com/Marfusios/nostr-client/actions/workflows/dotnet-core.yml/badge.svg)](https://github.com/Marfusios/nostr-client/actions/workflows/dotnet-core.yml) [![NuGet version](https://badge.fury.io/nu/Nostr.Client.svg)](https://badge.fury.io/nu/Nostr.Client) [![NuGet downloads](https://img.shields.io/nuget/dt/Nostr.Client)](https://www.nuget.org/packages/Nostr.Client)\n\nThis is a C# implementation of the Nostr protocol found here:\n\nhttps://github.com/nostr-protocol/nips\n\nNostr protocol is based on websocket communication. \nThis library keeps a reliable connection to get real-time data and fast execution of your commands. \n\n[Releases and breaking changes](https://github.com/Marfusios/nostr-client/releases)\n\n### License: \n    Apache License 2.0\n\n### Features\n\n* installation via NuGet ([Nostr.Client](https://www.nuget.org/packages/Nostr.Client))\n* targeting .NET 6.0 and higher (.NET Core, Linux/MacOS compatible)\n* reactive extensions ([Rx.NET](https://github.com/Reactive-Extensions/Rx.NET))\n\n### Usage\n\n#### Receiving events\n\n```csharp\nvar url = new Uri(\"wss://relay.damus.io\");\n\nusing var communicator = new NostrWebsocketCommunicator(url);\nusing var client = new NostrWebsocketClient(communicator, null);\n\nclient.Streams.EventStream.Subscribe(response =\u003e\n{\n    var ev = response.Event;\n    Log.Information(\"{kind}: {content}\", ev?.Kind, ev?.Content)\n            \n    if(ev is NostrMetadataEvent evm) {\n        Log.Information(\"Name: {name}, about: {about}\", evm.Metadata?.Name, evm.Metadata?.About);\n    }\n});\n\nawait communicator.Start();\n```\n\n#### Sending event\n\n```csharp\nvar ev = new NostrEvent\n{\n    Kind = NostrKind.ShortTextNote,\n    CreatedAt = DateTime.UtcNow,\n    Content = \"Test message from C# client\"\n};\n\nvar key = NostrPrivateKey.FromBech32(\"nsec1xxx\");\nvar signed = ev.Sign(key);\n\nclient.Send(new NostrEventRequest(signed));\n```\n\n#### Sending encrypted direct message (NIP-04)\n\n```csharp\nvar sender = NostrPrivateKey.FromBech32(\"nsec1l0a7m5dlg4h9wurhnmgsq5nv9cqyvdwsutk4yf3w4fzzaqw7n80ssdfzkg\");\nvar receiver = NostrPublicKey.FromBech32(\"npub1dd668dyr9un9nzf9fjjkpdcqmge584c86gceu7j97nsp4lj2pscs0xk075\");\n\nvar ev = new NostrEvent\n{\n    CreatedAt = DateTime.UtcNow,\n    Content = $\"Test private message from C# client\"\n};\n\nvar encrypted = ev.EncryptDirect(sender, receiver);\nvar signed = encrypted.Sign(sender);\n\nclient.Send(new NostrEventRequest(signed));\n```\n\n#### Multi relays support\n\n```csharp\nvar relays = new[]\n{\n    new NostrWebsocketCommunicator(new Uri(\"wss://relay.snort.social\")),\n    new NostrWebsocketCommunicator(new Uri(\"wss://relay.damus.io\")),\n    new NostrWebsocketCommunicator(new Uri(\"wss://nos.lol\"))\n};\n\nvar client = new NostrMultiWebsocketClient(NullLogger\u003cNostrWebsocketClient\u003e.Instance, relays);\n\nclient.Streams.EventStream.Subscribe(HandleEvent);\n\nrelays.ToList().ForEach(relay =\u003e relay.Start());\n```\n\nMore usage examples:\n* Tests ([link](tests/Nostr.Client.Tests))\n* Console sample ([link](test_integration/Nostr.Client.Sample.Console/Program.cs))\n* NostrDebug - Blazor app ([link](apps/nostr-debug/NostrDebug.Web), [deployed](https://nostrdebug.com))\n\n![image](https://raw.githubusercontent.com/Marfusios/nostr-client/master/apps/nostr-debug/NostrDebug.Web/wwwroot/nostr-preview.png)\n\n### NIP's coverage\n\n- [x] NIP-01: Basic protocol flow description\n- [x] NIP-02: Contact List and Petnames (No petname support)\n- [ ] NIP-03: OpenTimestamps Attestations for Events\n- [x] NIP-04: Encrypted Direct Message\n- [ ] NIP-05: Mapping Nostr keys to DNS-based internet identifiers\n- [ ] NIP-06: Basic key derivation from mnemonic seed phrase\n- [ ] NIP-07: `window.nostr` capability for web browsers\n- [ ] NIP-08: Handling Mentions\n- [ ] NIP-09: Event Deletion\n- [ ] NIP-10: Conventions for clients' use of `e` and `p` tags in text events\n- [ ] NIP-11: Relay Information Document\n- [ ] NIP-12: Generic Tag Queries\n- [ ] NIP-13: Proof of Work\n- [ ] NIP-14: Subject tag in text events\n- [x] NIP-15: End of Stored Events Notice\n- [x] NIP-19: bech32-encoded entities\n- [x] NIP-20: Command Results\n- [ ] NIP-21: `nostr:` Protocol handler (`web+nostr`)\n- [ ] NIP-25: Reactions\n- [ ] NIP-26: Delegated Event Signing (Display delegated signings only)\n- [ ] NIP-28: Public Chat\n- [ ] NIP-36: Sensitive Content\n- [ ] NIP-40: Expiration Timestamp\n- [ ] NIP-42: Authentication of clients to relays\n- [ ] NIP-50: Search\n- [ ] NIP-51: Lists\n- [ ] NIP-65: Relay List Metadata\n\n**Pull Requests are welcome!**\n\n### Reconnecting\n\nA built-in reconnection invokes after 1 minute (default) of not receiving any messages from the server. \nIt is possible to configure that timeout via `communicator.ReconnectTimeout`. \nAlso, a stream `ReconnectionHappened` sends information about a type of reconnection. \nHowever, if you are subscribed to low-rate channels, you will likely encounter that timeout - higher it to a few minutes or implement `ping-pong` interaction on your own every few seconds. \n\nIn the case of Nostr relay outage, there is a built-in functionality that slows down reconnection requests \n(could be configured via `client.ErrorReconnectTimeout`, the default is 1 minute).\n\nBeware that you **need to resubscribe to channels** after reconnection happens. You should subscribe to `ReconnectionHappened` stream and send subscription requests. \n\n### Testing\n\nThe library is prepared for replay testing. The dependency between `Client` and `Communicator` is via abstraction `INostrCommunicator`. There are two communicator implementations: \n* `NostrWebsocketCommunicator` - real-time communication with Nostr relay.\n* `NostrFileCommunicator` - a simulated communication, raw data are loaded from files and streamed.\n\nFeel free to implement `INostrCommunicator` on your own, for example, load raw data from database, cache, etc. \n\nUsage: \n\n```csharp\nvar communicator = new NostrFileCommunicator();\ncommunicator.FileNames = new[]\n{\n    \"data/nostr-data.txt\"\n};\ncommunicator.Delimiter = \"\\n\";\n\nvar client = new NostrWebsocketClient(communicator);\nclient.Streams.EventStream.Subscribe(trade =\u003e\n{\n    // do something with an event\n});\n\nawait communicator.Start();\n```\n\n### Multi-threading and other considerations\n\nSee [Websocket Client readme](https://github.com/Marfusios/websocket-client#multi-threading)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fblock-core%2Fnostr-client","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fblock-core%2Fnostr-client","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fblock-core%2Fnostr-client/lists"}