# @ldo/ldo

> `@ldo/ldo` is the primary interface for accessing Linked Data Objects given raw RDF.

Latest version **1.0.0-alpha.53** (published 2026-11-16) · MIT license · 0 weekly downloads

## Install

```sh
npm install @ldo/ldo
pnpm add @ldo/ldo
yarn add @ldo/ldo
bun add @ldo/ldo
```

## Health

**Score 70/100 (B)** — status: active.

Positive: has types; esm support; no vulnerabilities; recently updated; high maintenance score; high quality score.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 1.0.0-alpha.53 |
| Published | 2026-11-16 |
| First published | 2023-10-01 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=20.19.0 |
| Dependencies | 7 |
| Unpacked size | 171.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 73 |
| Author | Jackson Morgan |
| Maintainers | jaxoncreed |

## Links

- npm: https://www.npmjs.com/package/@ldo/ldo
- Repository: https://github.com/o-development/ldo
- Homepage: https://github.com/o-development/ldo/tree/main/packages/ldo#readme
- Issues: https://github.com/o-development/ldo/issues
- npm.io page: https://npm.io/package/@ldo/ldo

## Dependencies (7)

- [buffer](https://npm.io/package/buffer.md) ^6.0.3
- [@ldo/dataset](https://npm.io/package/@ldo/dataset.md) ^1.0.0-alpha.53
- [@rdfjs/types](https://npm.io/package/@rdfjs/types.md) ^1.0.1
- [@ldo/rdf-utils](https://npm.io/package/@ldo/rdf-utils.md) ^1.0.0-alpha.53
- [readable-stream](https://npm.io/package/readable-stream.md) ^4.3.0
- [@ldo/jsonld-dataset-proxy](https://npm.io/package/@ldo/jsonld-dataset-proxy.md) ^1.0.0-alpha.53
- [@ldo/subscribable-dataset](https://npm.io/package/@ldo/subscribable-dataset.md) ^1.0.0-alpha.53

## Recent versions

- 1.0.0-alpha.53 (latest) — 2026-11-16
- 1.0.0-alpha.51 — 2026-05-10
- 1.0.0-alpha.50 — 2026-05-09
- 1.0.0-alpha.48 — 2026-05-06
- 1.0.0-alpha.46 — 2026-03-19
- 1.0.0-alpha.45 — 2026-03-19
- 1.0.0-alpha.44 — 2026-03-18
- 1.0.0-alpha.43 — 2026-03-18
- 1.0.0-alpha.38 — 2026-03-10
- 1.0.0-alpha.36 — 2026-03-07
- 1.0.0-alpha.34 — 2026-03-07
- 1.0.0-alpha.32 — 2025-08-20
- 1.0.0-alpha.31 — 2025-08-20
- 1.0.0-alpha.30 — 2025-08-01
- 1.0.0-alpha.28 — 2025-07-04
- … 21 more at https://npm.io/package/@ldo/ldo/versions

## README

# @ldo/ldo

`@ldo/ldo` is the primary interface for accessing Linked Data Objects given raw RDF.

## Guide

A full walkthrough for using the `@ldo/ldo` library can be found in the [For RDF Usage Guide](https://ldo.js.org/latest/raw_rdf/).

## Installation

### Automatic Installation

Navigate into your project's root folder and run the following command:

```
cd my_project/
npx run @ldo/cli init
```

<details>
<summary>
Manual Installation
</summary>

If you already have generated ShapeTypes, you may install the `@ldo/ldo` library independently.

```
npm i @ldo/ldo
```

</details>

## Simple Example

Below is a simple example of LDO in a real use-case (changing the name on a Solid Pod). Assume that a ShapeType was previously generated and placed at `./_ldo/foafProfile.shapeTypes`.

```typescript
import {
  parseRdf,
  startTransaction,
  toSparqlUpdate,
  toTurtle,
  set,
} from "@ldo/ldo";
import { FoafProfileShapeType } from "./_ldo/foafProfile.shapeTypes.js";

async function run() {
  const rawTurtle = `
  <#me> a <http://xmlns.com/foaf/0.1/Person>;
      <http://xmlns.com/foaf/0.1/name> "Jane Doe".
  `;

  /**
   * Step 1: Convert Raw RDF into a Linked Data Object
   */
  const ldoDataset = await parseRdf(rawTurtle, {
    baseIRI: "https://solidweb.me/jane_doe/profile/card",
  });
  // Create a linked data object by telling the dataset the type and subject of
  // the object
  const janeProfile = ldoDataset
    // Tells the LDO dataset that we're looking for a FoafProfile
    .usingType(FoafProfileShapeType)
    // Says the subject of the FoafProfile
    .fromSubject("https://solidweb.me/jane_doe/profile/card#me");

  /**
   * Step 2: Manipulate the Linked Data Object
   */
  // Logs "Jane Doe"
  console.log(janeProfile.name);
  // Logs "Person"
  console.log(janeProfile.type);
  // Logs 0
  console.log(janeProfile.knows?.size);

  // Begins a transaction that tracks your changes
  startTransaction(janeProfile);
  janeProfile.name = "Jane Smith";
  janeProfile.knows?.add({
    "@id": "https://solidweb.me/john_smith/profile/card#me",
    type: {
      "@id": "Person",
    },
    name: "John Smith",
    knows: set(janeProfile),
  });

  // Logs "Jane Smith"
  console.log(janeProfile.name);
  // Logs "John Smith"
  console.log(janeProfile.knows?.toArray()[0].name);
  // Logs "Jane Smith"
  console.log(janeProfile.knows?.toArray()[0].knows?.toArray()[0].name);

  /**
   * Step 3: Convert it back to RDF
   */
  // Logs:
  // <https://solidweb.me/jane_doe/profile/card#me> a <http://xmlns.com/foaf/0.1/Person>;
  //   <http://xmlns.com/foaf/0.1/name> "Jane Smith";
  //   <http://xmlns.com/foaf/0.1/knows> <https://solidweb.me/john_smith/profile/card#me>.
  // <https://solidweb.me/john_smith/profile/card#me> a <http://xmlns.com/foaf/0.1/Person>;
  //   <http://xmlns.com/foaf/0.1/name> "John Smith";
  //   <http://xmlns.com/foaf/0.1/knows> <https://solidweb.me/jane_doe/profile/card#me>.
  console.log(await toTurtle(janeProfile));
  // Logs:
  // DELETE DATA {
  //   <https://solidweb.me/jane_doe/profile/card#me> <http://xmlns.com/foaf/0.1/name> "Jane Doe" .
  // };
  // INSERT DATA {
  //   <https://solidweb.me/jane_doe/profile/card#me> <http://xmlns.com/foaf/0.1/name> "Jane Smith" .
  //   <https://solidweb.me/jane_doe/profile/card#me> <http://xmlns.com/foaf/0.1/knows> <https://solidweb.me/john_smith/profile/card#me> .
  //   <https://solidweb.me/john_smith/profile/card#me> <http://xmlns.com/foaf/0.1/name> "John Smith" .
  //   <https://solidweb.me/john_smith/profile/card#me> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://xmlns.com/foaf/0.1/Person> .
  //   <https://solidweb.me/john_smith/profile/card#me> <http://xmlns.com/foaf/0.1/knows> <https://solidweb.me/jane_doe/profile/card#me> .
  // }
  console.log(await toSparqlUpdate(janeProfile));
}
run();
```

## API Details

Types

- [`LdoBase`](https://ldo.js.org/latest/api/ldo/LdoBase/)
- [`ShapeType`](https://ldo.js.org/latest/api/ldo/ShapeType/)

Getting an LdoDataset

- [`parseRdf`](https://ldo.js.org/latest/api/ldo/parseRdf/)
- [`createLdoDatasetFactory`](https://ldo.js.org/latest/api/ldo/createLdoDatasetFactory/)
- [`LdoDatasetFactory`](https://ldo.js.org/latest/api/ldo/LdoDatasetFactory/)
- [`createLdoDataset`](https://ldo.js.org/latest/api/ldo/createLdoDataset/)
- [`LdoDataset`](https://ldo.js.org/latest/api/ldo/LdoDataset/)

Getting a Linked Data Object

- [`LdoBuilder`](https://ldo.js.org/latest/api/ldo/LdoBuilder/)

Converting a Linked Data Object to Raw RDF

- [`toTurtle`](https://ldo.js.org/latest/api/ldo/toTurtle/)
- [`toNTriples`](https://ldo.js.org/latest/api/ldo/toNTriples/)
- [`serialize`](https://ldo.js.org/latest/api/ldo/serialize/)

Transactions

- [transactions](https://ldo.js.org/latest/api/ldo/transactions/)
- [`toSparqlUpdate`](https://ldo.js.org/latest/api/ldo/toSparqlUpdate/)

Language Tag Support

- [`languageOf`](https://ldo.js.org/latest/api/ldo/languageOf/)
- [`setLanguagePreferences`](https://ldo.js.org/latest/api/ldo/setLanguagePreferences/)

Graph Support

- [`graphOf`](https://ldo.js.org/latest/api/ldo/graphOf/)
- [`write`](https://ldo.js.org/latest/api/ldo/write/)

Other Helper Functions

- [`getDataset`](https://ldo.js.org/latest/api/ldo/getDataset/)

## Sponsorship

This project was made possible by a grant from NGI Zero Entrust via nlnet. Learn more on the [NLnet project page](https://nlnet.nl/project/SolidUsableApps/).

[<img src="https://nlnet.nl/logo/banner.png" alt="nlnet foundation logo" width="300" />](https://nlnet.nl/)
[<img src="https://nlnet.nl/image/logos/NGI0Entrust_tag.svg" alt="NGI Zero Entrust Logo" width="300" />](https://nlnet.nl/)

## License

MIT

---
_Source: https://npm.io/package/@ldo/ldo · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
