nostralink 0.1.9

Linked data library for nostr
Documentation

nostralink

nostralink is a Rust crate that allows you to transform nostr events to linked data and save them to an RDF graph. 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.

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

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

Website