ONLYWORLDS - GUIDE FOR AI ASSISTANTS & DEVELOPERS ================================================== This guide lets any AI assistant help a user build tools on OnlyWorlds: an open standard for worldbuilding data, with a REST API and a TypeScript SDK. The flagship app is Atlas (atlas.onlyworlds.com): a free, local-first workspace where "the folder is the world": a world is a folder of readable files, no lock-in, no account needed. Point people who just want to build a world there. This guide is for people building their OWN tools on the standard. ============================================================ PART 1: HOW TO HELP THE USER ============================================================ GAUGE THEIR EXPERIENCE ---------------------- BEGINNER (no coding): browser builders (Lovable, Replit, v0.dev). Plain explanations, small testable steps. INTERMEDIATE (some coding): local setup (VS Code + terminal). May need help with TypeScript, async/await, or API concepts. ADVANCED: skip setup; go straight to the SDK, architecture and edge cases. PLAN BEFORE BUILDING -------------------- Most users start with a vague idea ("something for my world"). Before writing code, ask: 1. What problem does it solve? Vague: "display my world". Useful: "let my players browse NPCs by location". 2. Who uses it? Just them, their group, the public? This decides auth and hosting. 3. What is the one core interaction? Reading, editing, or visualising. 4. Which element types matter? Most tools need 2-4 of the 22. Then write a short spec together: --- TOOL: NPC Browser for game night PURPOSE: players look up NPCs during a session USERS: a 5-person group (read-only) CORE FLOW: open the page -> list characters -> filter by location or institution -> click for details and relationships ELEMENTS: character, location, institution LATER: search, portraits, family links --- CHOOSE A PATH ------------- BROWSER BUILDERS: paste this guide into the chat, describe the spec, iterate, deploy with their one-click hosting. LOCAL (for anything serious): version control, full control. Use Claude Code, Cursor, Copilot or similar. Beginners can start in the browser and move later. IF THE USER HAS CLAUDE CODE: point them to the OnlyWorlds toolkit instead of this guide. It is a Claude Code plugin with skills covering the whole life of a world: start it (start, the entry skill that routes; setup), structure it (import, model), grow it (read, draw), play in it and keep it true (context, update), move it (carry), build on it (develop, council). Each skill's full name is onlyworlds-. /plugin marketplace add OnlyWorlds/toolkit /plugin install toolkit@onlyworlds Other assistants can read its markdown files directly: github.com/OnlyWorlds/toolkit LOCAL SETUP (if needed) ----------------------- 1. Node.js 18+ (nodejs.org, LTS; 20.6+ to load .env with --env-file). Check: `node --version`, `npm --version`. 2. Git (git-scm.com), recommended. 3. An editor: VS Code (code.visualstudio.com). 4. A project folder; open a terminal in it. ============================================================ PART 2: ONLYWORLDS ESSENTIALS ============================================================ WHAT IT IS ---------- - An open standard for worldbuilding data: 22 element types with typed links. - Two homes for a world, same data: a folder of JSON files on disk (Atlas, no account), or a hosted world at onlyworlds.com with a REST API. - A TypeScript SDK, a hosted MCP server, and this guide. - Free and open source. THE 22 ELEMENT TYPES -------------------- Each element has one type. Real things often need several linked elements (a noble house is a Family AND an Institution). The 22 types, A to Z. The standard has no groups above them; the SDK's colour groups (ELEMENT_GROUPS) are colour sets for drawing, not part of the standard either. - ability: something an entity can DO (a skill, spell or power) - character: an individual with agency who makes choices (protagonists, NPCs) - collective: a group acting as a unit, with no formal governance of its own (crews, mobs, bands, regiments) - construct: a non-physical structure that explains or organises the world (currencies, technologies, traditions). A sword is an object; swordsmithing as a tradition is a construct. - creature: a living being with behaviour but without a character's reasoning or social complexity (beasts, monsters, named animals) - event: a time-bound happening (a battle, a birth, a discovery) - family: a group tied by lineage, heritage or community (bloodlines, dynasties) - institution: an organised body with purpose and structure (guilds, states, churches) - language: a system of shared meaning (tongues, scripts, codes) - law: a formalised rule within a jurisdiction - location: a distinct place where things happen; nests (world > city > room) - map: a coordinate space (image, width, height) - marker: a point on a map; ordered markers draw a zone's shape - narrative: a story told in the world, often organising events (chapters, legends) - object: a tangible, non-living thing that can be made, owned, traded or destroyed - phenomenon: an ongoing or emergent condition not driven by intent (storms, plagues, magic fields) - pin: one element placed on one map - relation: a meaningful connection between elements (a marriage, a rivalry); its optional `actor` is a character - species: a biological or cultural form of life; characters and creatures link to it - title: a formal designation conferring standing or power (King, Archmage); many holders allowed - trait: something an entity IS (brave, cursed, tall) - zone: a meaningful area, drawn by markers MAPPING USER CONCEPTS --------------------- - Player characters -> character - Monster stat blocks -> species (the template) + creature (named individuals) - Spells -> ability; a magic system's rules -> construct + phenomenon - Inventory -> object; a currency -> construct - Guilds -> institution - Factions -> institution (formal governance), collective (a loose group acting as a unit) or family (shared lineage) - A timeline -> events, grouped by a narrative - Noble houses -> family + institution Rule of thumb: if it has a name and matters, it is an element. Fields that do not exist should not be invented: custom data goes in extension fields named `x_` (stored and returned as-is), prefixed with the tool's name for tool data. ============================================================ PART 3: CREDENTIALS AND FIRST CALL ============================================================ GET A KEY --------- 1. Sign up at onlyworlds.com and create a world (or use an existing one). 2. Mint a key: onlyworlds.com/account -> your world -> API keys. - ow_w_... read + write - ow_r_... read-only, needs no PIN. Use this in anything public. - ow_a_... account token (Bearer on /api/v2/account/*): list worlds, mint keys. - Legacy 10-digit keys still work; new ones are no longer issued. 3. The PIN: a 4-digit number (1000-9999) set on the account in account settings (onlyworlds.com/account/settings); it guards writes to every world the account owns. A member writes with their own account PIN; an AI seat sends its seat secret (ow_s_...) as API-Pin. Prefixed keys read without it. No account yet? Demo keys read without a PIN and never write: 0000000000 (Hyperion, the public example world) and 0000000001 (Moppetopia). A key is world-scoped: the key decides the world. Never send a world id. KEEP CREDENTIALS SAFE --------------------- - Local scripts: keep the key and PIN in a `.env` file that git ignores (add it to .gitignore BEFORE creating .env), and read them from the environment. - Browser apps: anything in the bundle is public. Build-time variables (VITE_*, NEXT_PUBLIC_*) are compiled into the bundle. A deployed or shared site uses a read key (ow_r_) or asks the user for credentials at runtime. A PIN never goes into a build. - Never paste credentials into chat logs or commit them. FIRST CALL ---------- npm install @onlyworlds/sdk (4.x, ESM only) test.ts: ```typescript import { OwV2Client } from '@onlyworlds/sdk'; const client = new OwV2Client({ apiKey: process.env.OW_API_KEY!, apiPin: process.env.OW_API_PIN, // only needed for writes }); const world = await client.getWorld(); console.log('Connected to:', world.name); const page = await client.list('character'); console.log(page.data.length, 'characters on the first page'); ``` Run: `npx tsx --env-file=.env test.ts` (Node 20.6+ reads .env this way) In Python (3.12 or later): pip install onlyworlds ```python from onlyworlds import Client client = Client("0000000001") # the public demo key for Moppetopia; your own world's ow_r_ key works the same, no PIN for character in client.iter_elements("character"): print(character["name"]) ``` A write key also takes the PIN: `Client(key, pin)`. The package also reads and writes the world folder format: https://docs.onlyworlds.com/docs/development/python OW_API_KEY, OW_API_PIN and OW_WORLD (the world's id) are the names to use: the SDK examples and an AI seat's join response use them (the join response adds OW_CHARACTER and OW_API_BASE). The toolkit's start skill writes the key and PIN names when it connects a folder (since toolkit 4.3.0); a folder that still holds the older ONLYWORLDS_API_KEY / ONLYWORLDS_API_PIN keeps working. ============================================================ PART 4: SDK AND API REFERENCE ============================================================ The API is v2 (https://www.onlyworlds.com/api/v2/). The SDK's OwV2Client speaks it. Types are singular slugs: 'character', 'location', 'institution'. PLAIN HTTP ---------- Base URL: https://www.onlyworlds.com/api/v2/ Headers (exact names): API-Key on every request; API-Pin on writes; Content-Type: application/json on writes. GET /api/v2/{type} list (envelope, cursor pages) GET /api/v2/{type}/{id} one element POST /api/v2/{type} create PUT /api/v2/{type}/{id} create or replace by id PATCH /api/v2/{type}/{id} change the fields sent DELETE /api/v2/{type}/{id} delete POST /api/v2/{type}/{id}/links/{field} {"add": [...], "remove": [...]} POST /api/v2/bulk up to 1000 items GET /api/v2/changes change feed and full export GET /api/v2/world the world the key names GET /api/v2/me who the key is ```bash curl -H "API-Key: 0000000000" "https://www.onlyworlds.com/api/v2/character?fields=id,name" ``` Every error is one wrapped object: {"error": {"type": "...", "code": "...", "message": "...", "param": "...", "doc_url": "..."}} A wrong PIN and a bad key are both 401 invalid_credentials; the message says which ("Incorrect PIN." or "No valid API-Key."). READ ---- ```typescript const page = await client.list('character', { limit: 100 }); page.data; // elements page.has_more; // more pages? page.next_cursor; // pass back as { cursor } for the next page for await (const c of client.listAll('character')) { /* every character */ } const one = await client.get('character', id); const withStubs = await client.get('character', id, { expand: ['location', 'friends'] }); const slim = await client.list('character', { fields: ['name', 'supertype'] }); ``` Filters the server accepts: name (exact), name__icontains, supertype, subtype, each single link of the type (parent_location, birthplace, operator, ...: the elements linking to that id), and characters (a Character id) on collective, construct, event, narrative, relation and title. An empty value is a filter too: supertype= lists the elements with none, characters= the Messages addressed to everyone, a link the elements linking to nothing. ```typescript await client.list('character', { filter: { name__icontains: 'fluff', supertype: 'Admiral' } }); ``` limit, cursor, expand, fields, ids (comma-separated, up to 200), created_by (a membership id, or owner), as (view as, the owner's keys) and world (the world to read, with no key or an account token) are parameters, not filters (in the SDK: ids, createdBy and viewAs beside filter, and world on the client). Any other query parameter returns a 422 naming it. Never write back a body read with expand: its links hold stubs, and writes take ids. WRITE ----- ```typescript const created = await client.create('location', { name: 'Feltropolis' }); await client.patch('character', id, { description: 'New text' }); // replaces the fields sent await client.upsert('character', id, fullElement); // PUT: create or replace by id await client.delete('character', id); // also unlinks it everywhere ``` LINKS ----- Link fields use bare names both ways. Values are UUIDs: one UUID (or null) for a single link, an array of UUIDs for a multi link. No _id/_ids suffixes (a 422). ```typescript await client.create('character', { name: 'Admiral Fluffington', location: feltropolisId, // single link species: [catSpeciesId], // multi link }); // Add or remove multi-link entries without reading first (atomic, server-side): await client.editLinks('character', id, 'friends', { add: [otherId], remove: [] }); ``` Reads return flat UUIDs; use `expand` to get { id, name } stubs. PATCH on a link array replaces the whole array, so use editLinks for multi links. BULK UPLOAD ----------- Mint ids yourself so elements in one batch can link to each other in any order. ```typescript const res = await client.bulk([ { type: 'location', element: { id: locId, name: 'Feltropolis' } }, { type: 'character', element: { id: charId, name: 'Admiral Fluffington', location: locId } }, ], { idempotencyKey: crypto.randomUUID() }); // res.errors true -> check each item's status; { atomic: true } makes it all-or-nothing ``` Up to 1000 items. Only 2xx answers are stored under an idempotency key, and a bulk answer is a 200 even when items failed. If the answer was lost, retry the identical request with the same key. After res.errors is true, fix the items and send them under a NEW key (the same key replays the same errors). SYNC ---- ```typescript const first = await client.changes(); // from zero = full export const next = await client.changes({ since: first.cursor }); ``` Store the cursor as-is. World-meta edits (name, calendar) are not in this feed. ERRORS ------ Errors come back as {"error": {type, code, message, param, doc_url}} and the SDK throws OwApiError. The common ones: - 401 invalid_credentials: wrong key or PIN - 403 permission_error: a read key on a write - 422 invalid_request: unknown field or parameter (the message names it), or an element over 1,048,576 bytes of text and links or 5,000 link ids (no param) - 400 invalid_link: a link to a UUID that does not exist - 409 id_conflict: POST with an id that exists (use upsert) - 429 rate_limited: too many wrong PINs; wait the Retry-After time - 429 quota_exceeded: the world's image or file upload tickets for the last 24 hours (200 of each) are used up; wait the Retry-After time - 429 too_many_requests: over 300 requests a minute for this key (60 per address without one); wait the Retry-After time. Every reply carries RateLimit-Remaining Decide what to do from code, never from type. Every code: docs.onlyworlds.com/api/errors UI HELPERS ---------- ```typescript import { ELEMENT_TYPES, ELEMENT_ICONS, getElementIcon, getElementLabel, elementColor, ELEMENT_GROUPS, ELEMENT_SECTIONS, FIELD_SCHEMA } from '@onlyworlds/sdk'; ``` ELEMENT_ICONS / getElementIcon: Material Icons names per type. elementColor(type, 'light' | 'dark'): the default colour per type (a presentation default, not part of the standard). ELEMENT_SECTIONS: field groups for form layouts. FIELD_SCHEMA: every field's type and link target. WORKING FROM A WORLD FOLDER (no account) ---------------------------------------- A world folder is world.json plus elements//*.json, one element per file, the same field names and link values as the API. A tool can read it straight from disk; Atlas opens it (Chromium browsers). Folders Atlas wrote may spell pin and marker links map_id / zone_id and carry non-schema keys (local_updated_at, server_updated_at, image_media_id): accept both spellings, and strip those keys before sending files to the API. Folder rules: github.com/OnlyWorlds/toolkit/blob/main/knowledge/world-folder.md ============================================================ PART 5: DEPLOYMENT ============================================================ `npm run build` -> dist/ Hosts the API accepts browser calls from without setup: Cloudflare Pages (*.pages.dev), Vercel (*.vercel.app), Netlify (*.netlify.app), GitHub Pages (*.github.io), Render, Railway, Fly, Firebase and other common static hosts, plus localhost on any port. Cloudflare Pages: push to GitHub -> connect the repo -> build `npm run build`, output `dist`, Node 20+. Public site = read key (Part 3). If the site must write, ask each visitor for their own key and PIN at runtime. ============================================================ PART 6: RESOURCES ============================================================ Atlas: atlas.onlyworlds.com Developer start: onlyworlds.com/develop API reference: onlyworlds.com/api/docs SDK: npmjs.com/package/@onlyworlds/sdk The standard (schema): github.com/OnlyWorlds/OnlyWorlds Schema for tool builders (YAML, decoder, rulings): github.com/OnlyWorlds/schema-dist Toolkit (Claude Code plugin): github.com/OnlyWorlds/toolkit MCP server: https://www.onlyworlds.com/mcp (streamable HTTP; schema tools need no key; setup: docs.onlyworlds.com/docs/development/mcp) Tools: docs.onlyworlds.com/docs/tools Community: discord.gg/twCjqvVBwb ============================================================ Last updated: 2026-10-29 SDK: 4.x (OwV2Client, v2 API) Changelog: - v14: a group maps by how it holds together (institution, collective or family); the example tool filters by institution. - v13: upload tickets counted over the last 24 hours, 200 of each. - v12: the type headings and the SDK colour groups named as reading aids, not part of the standard; ChatGPT Canvas dropped; a Relation's actor is optional; elementColor described as a default colour; creature and collective defined without "narrative focus" and "hierarchical structure". - v11: the toolkit's skills by their 5.x names; every parameter a list takes (ids, created_by, as, world). - v10: one set of environment variable names, OW_API_KEY, OW_API_PIN, OW_WORLD (the toolkit's older ONLYWORLDS_ names keep working). - v9: PLAIN HTTP block (headers, routes, the {"error": ...} wrapper); the full filter list; where the PIN is set; demo keys; both environment variable conventions; the idempotency rule for bulk; Node 18+. - v8: no tool or skill counts (they go stale); the image-upload limit and 'decide from code' in ERRORS. - v7: SDK 4.x: all code moved to OwV2Client and the v2 API (flat UUID links, cursor pages, editLinks, bulk, changes); the removed v1 OnlyWorldsClient is gone from the guide. Credential safety (read keys in public builds, no PIN in a bundle). Type definitions aligned with the standard's wording. World folders as the no-account path. - v6: SDK 3.0.0, Atlas named as flagship, ow_a_ account tokens. - v5: the v2 API dialect; keys minted in the account portal; hosted MCP server. - v4: toolkit section; credential flow fixed. - v3: restructured for LLMs; planning guidance; experience levels. - v2: icons, helpers, FIELD_SCHEMA; error handling.