3 unstable releases

new 0.2.1 May 19, 2025
0.2.0 May 19, 2025
0.1.9 May 18, 2025

#1397 in Web programming

47 downloads per month

Apache-2.0 and GPL-3.0 licenses

190KB
5K SLoC

nostralink

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.

JSON-LD contexts for various content types are provided, as well as SparQL queries for common operations.

Discuss

IRC: #nostralink channel on libera.chat.

Usage

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(())
}

Projects using nostralink

  • paz is an experimental nostr client built with nostralink and egui.

Examples

Client

This example fetches recent notes to a store, and shows each incoming event in the ttl (Turtle) format.

cargo run -r --example client

Resources

Dependencies

~46–86MB
~1.5M SLoC