
Company News
Socket Named Top Sales Organization by RepVue
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.
@onlyworlds/sdk
Advanced tools
TypeScript SDK for the OnlyWorlds API - build world-building applications with type safety
Type-safe SDK for building applications with the OnlyWorlds API. Access all 22 element types with full TypeScript support.
npm install @onlyworlds/sdk
# or
yarn add @onlyworlds/sdk
import { OnlyWorldsClient } from '@onlyworlds/sdk';
// Initialize the client
const client = new OnlyWorldsClient({
apiKey: 'your-api-key',
apiPin: 'your-api-pin'
});
// Create a character
const character = await client.characters.create({
name: 'Aragorn',
description: 'Heir of Isildur',
location_id: 'uuid-of-location',
abilities_ids: ['uuid1', 'uuid2']
});
// List locations with filtering
const locations = await client.locations.list({
search: 'tavern',
ordering: '-created_at',
limit: 10
});
_id/_ids pattern automaticallyThe SDK supports all 22 OnlyWorlds element types:
import { OnlyWorldsClient } from '@onlyworlds/sdk';
const client = new OnlyWorldsClient({
apiKey: 'your-api-key', // Required
apiPin: 'your-api-pin', // Required
baseUrl: 'custom-url' // Optional, defaults to onlyworlds.com
});
All element types support the same operations:
// List with filtering
const items = await client.characters.list({
search: 'hero',
ordering: 'name',
limit: 20,
offset: 0
});
// Get single item
const character = await client.characters.get('uuid');
// Create new item
const newChar = await client.characters.create({
name: 'Gandalf',
description: 'A wizard'
});
// Update existing item
const updated = await client.characters.update('uuid', {
description: 'A wizard, also known as Mithrandir'
});
// Delete item
await client.characters.delete('uuid');
The SDK handles OnlyWorlds' _id/_ids pattern automatically:
// Creating with relationships
const character = await client.characters.create({
name: 'Frodo',
birthplace_id: 'location-uuid', // Single relationship
abilities_ids: ['uuid1', 'uuid2'], // Multi relationship
friends_ids: ['sam-uuid', 'merry-uuid']
});
// The response includes nested objects
console.log(character.birthplace.name); // "The Shire"
console.log(character.abilities[0].name); // "Ring Bearer"
All types are exported for your use:
import {
Character,
CharacterInput,
Location,
ElementType
} from '@onlyworlds/sdk';
// Use in your functions
function createHero(data: CharacterInput): Promise<Character> {
return client.characters.create(data);
}
// Element type enum
console.log(ElementType.Character); // 'character'
// Create multiple related elements
async function createParty(partyData: any[]) {
const location = await client.locations.create({
name: 'Tavern',
description: 'Where the party meets'
});
const characters = await Promise.all(
partyData.map(data =>
client.characters.create({
...data,
location_id: location.id
})
)
);
return { location, characters };
}
// Find all wizards in a specific location
const wizards = await client.characters.list({
search: 'wizard',
location: 'location-uuid',
ordering: '-level'
});
// Get recently updated items
const recent = await client.events.list({
ordering: '-updated_at',
limit: 5
});
try {
const character = await client.characters.get('invalid-uuid');
} catch (error) {
if (error.message.includes('404')) {
console.log('Character not found');
}
}
OnlyWorlds uses different formats for requests and responses:
_id for single relationships, _ids for multipleThe SDK provides separate types for each:
// CharacterInput for creating/updating
interface CharacterInput {
name: string;
location_id?: string; // UUID string
abilities_ids?: string[]; // Array of UUIDs
}
// Character for responses
interface Character {
name: string;
location?: Location; // Full nested object
abilities?: Ability[]; // Array of full objects
}
// Convert nested objects to _id/_ids format
const input = OnlyWorldsClient.prepareInput({
name: 'Test',
location: { id: 'uuid', name: 'Place' },
abilities: [{ id: 'uuid1' }, { id: 'uuid2' }]
});
// Result: { name: 'Test', location_id: 'uuid', abilities_ids: ['uuid1', 'uuid2'] }
This SDK works in browsers, but you'll need to handle CORS:
// For development, use a proxy or CORS-enabled server
// Never expose API credentials in client-side code!
// Better approach: Use a backend proxy
const response = await fetch('/api/proxy/onlyworlds', {
method: 'POST',
body: JSON.stringify({ /* your request */ })
});
MIT
FAQs
TypeScript SDK for the OnlyWorlds API - build world-building applications with type safety
The npm package @onlyworlds/sdk receives a total of 7 weekly downloads. As such, @onlyworlds/sdk popularity was classified as not popular.
We found that @onlyworlds/sdk demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Company News
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.

Security News
NIST will stop enriching most CVEs under a new risk-based model, narrowing the NVD's scope as vulnerability submissions continue to surge.

Company News
/Security News
Socket is an initial recipient of OpenAI's Cybersecurity Grant Program, which commits $10M in API credits to defenders securing open source software.