| Crates.io | nostralink |
| lib.rs | nostralink |
| version | 0.2.3 |
| created_at | 2025-05-18 17:13:48.96038+00 |
| updated_at | 2025-06-01 02:09:07.783082+00 |
| description | Linked data library for nostr |
| homepage | |
| repository | https://codeberg.org/nostralink/nostralink |
| max_upload_size | |
| id | 1678782 |
| size | 421,075 |
nostralink is a Rust crate that allows you to transform nostr events to linked data and save them to an RDF triple store. It also offers APIs to write events as linked data (using JSON-LD) and make queries.
Uses the great oxigraph with oxjsonld for fast conversion to RDF.
Provides a nostr-database adapter so that you can easily hook a nostr client to an events store. Checkout the client example.
Uses SparQL to make queries on the events graph.
JSON-LD contexts for various content types are provided, as well as SparQL queries for common operations.
IRC: #nostralink channel on libera.chat.
use nostralink::prelude::*;
use std::path::PathBuf;
#[tokio::main]
async fn main() -> Result<(), RdfStoreError> {
let keys = Keys::generate();
let store = RdfEventsStore::open(PathBuf::from("store")).expect("Cannot open store");
let client = Client::builder().database(store).signer(keys).build();
client.add_relay("wss://relay.damus.io").await?;
client
.subscribe(
Filter::new()
.kind(Kind::TextNote)
.limit(50)
.since(Timestamp::now() - 3600),
None,
)
.await?;
Ok(())
}
This example fetches recent notes to a store, and shows each incoming event in the ttl (Turtle) format.
cargo run -r --example client