@triply/triplydb
    Preparing search index...

    @triply/triplydb

    The JavaScript and TypeScript client for TriplyDB: create and load datasets, manage services, run saved queries, and read data back. This is the API reference, generated from the source.

    • NodeJs 20 or newer. The package is built for ES2023.
    • An API token, if you want to do anything beyond reading public data. Create one in the TriplyDB web interface under your user settings, at /me/-/settings/tokens. Keep it out of your source — the examples below read it from the environment.
    npm install @triply/triplydb
    
    import App from "@triply/triplydb";

    const app = App.get({ token: process.env.TOKEN });

    const me = await app.getUser();
    console.log("connected as", (await me.getInfo()).accountName);
    const dataset = await me.ensureDataset("my-dataset", { accessLevel: "private" });

    await dataset.importFromFiles(["./data.trig"]);

    console.log((await dataset.getInfo()).statements, "statements");

    ensureDataset creates the dataset the first time and returns the existing one afterwards, so this is safe to re-run. importFromFiles uploads and waits for the server to finish, so once it resolves the data is queryable. Use a quad format such as TriG to control which graph statements land in; for a triple format, name the graph with importFromFiles(files, { defaultGraphName }).

    Statements can be read straight from the dataset:

    for await (const statement of dataset.getStatements({ predicate: "http://www.w3.org/2000/01/rdf-schema#label" })) {
    console.log(statement);
    }

    Iterators fetch pages as you consume them, so a large result set never has to fit in memory.

    Everything is in the sidebar, grouped into three categories. Reference holds the classes you work with. Types holds the shapes they accept and return — the *Info types are what getInfo() gives you, and the option types are what the methods take. Utilities holds what you receive rather than build: the iterators, the errors, and the response cache.

    Each class says which call produces one, so if you have found a page and cannot see how to obtain the object, that is where to look.

    The changelog lists the breaking changes, additions and fixes for each release, with the replacement for anything that was removed. It ships in the npm package too, as CHANGELOG.md.