Skip to main content

Setup

To get started, you’ll need an API key and a World ID. You can get these from the Worlds Console.

1. Install the SDK

npm install @fartlabs/worlds

2. Initialize the Client

import { World } from "@fartlabs/worlds";

const world = new World({
  baseUrl: "https://api.wazoo.tech/v1", // Adjust if using a different endpoint
  apiKey: "YOUR_API_KEY",
  worldId: "YOUR_WORLD_ID",
});

3. Add Knowledge

Insert some data into your world using SPARQL.
await world.sparqlUpdate(`
  INSERT DATA {
    <http://example.org/ethan> <http://schema.org/name> "Ethan" .
    <http://example.org/ethan> <http://schema.org/jobTitle> "Software Engineer" .
  }
`);

4. Query Knowledge

Retrieve the data you just added.
const result = await world.sparqlQuery(`
  SELECT ?name ?title WHERE {
    ?person <http://schema.org/name> ?name ;
            <http://schema.org/jobTitle> ?title .
  }
`);

console.log(result);
Perform a semantic search.
const searchResults = await world.search("Who is the software engineer?");
console.log(searchResults);