Returns all assets owned by User when an email address is provided.
Returns all platform assets.
Returns the platform assets or an error response.
Add a new avatar
const animationMeta = {
"emote": { "loop": false, "x": 0, "y": 0, "hideLoop": true }
}
const spriteSheetJSON = {
"animations": {
"emote": [
"emote/1.png"
]
},
"frames": {
"emote/1.png": {
"frame": {
"x": 1911,
"y": 778,
"w": 58,
"h": 91
},
"rotated": true,
"trimmed": true,
"spriteSourceSize": {
"x": 50,
"y": 33,
"w": 58,
"h": 91
},
"sourceSize": {
"w": 159,
"h": 159
}
}
},
"spriteSheetTypeMeta": {
"nameplate": {
"x": 0,
"y": -70
}
},
"meta": {
"image": "spriteSheets%2FTvHNjgoMkiErDNSrVqHU%2FspriteSheet.png?alt=media",
"format": "RGBA8888",
"size": {
"w": 2006,
"h": 1099
},
"scale": "1"
}
}
const formData = new FormData();
formData.append('animationMeta', animationMeta);
formData.append('name', "ExampleAvatarName");
formData.append('spriteSheetJSON', spriteSheetJSON);
formData.append('expression_dance', expression_dance);
formData.append('expression_emote', expression_emote);
formData.append('expression_sit', expression_sit);
formData.append('expression_stand', expression_stand);
formData.append('expression_transport', expression_transport);
formData.append('preview', preview);
formData.append('spriteSheet', spriteSheet);
formData.append('unityPackage', unityPackage);
await user.uploadAvatarFiles("exampleAvatarId", formData);
Update avatar and sprite sheet records and upload files to existing sprite sheet and avatar storage buckets
Returns all avatars owned by User
Returns the avatars or an error.
Update avatar and sprite sheet records and upload files to existing sprite sheet and avatar storage buckets
const animationMeta = {
"emote": { "loop": false, "x": 0, "y": 0, "hideLoop": true }
}
const spriteSheetJSON = {
"animations": {
"emote": [
"emote/1.png"
]
},
"frames": {
"emote/1.png": {
"frame": {
"x": 1911,
"y": 778,
"w": 58,
"h": 91
},
"rotated": true,
"trimmed": true,
"spriteSourceSize": {
"x": 50,
"y": 33,
"w": 58,
"h": 91
},
"sourceSize": {
"w": 159,
"h": 159
}
}
},
"spriteSheetTypeMeta": {
"nameplate": {
"x": 0,
"y": -70
}
},
"meta": {
"image": "spriteSheets%2FTvHNjgoMkiErDNSrVqHU%2FspriteSheet.png?alt=media",
"format": "RGBA8888",
"size": {
"w": 2006,
"h": 1099
},
"scale": "1"
}
}
const formData = new FormData();
formData.append('animationMeta', animationMeta);
formData.append('name', "ExampleAvatarName");
formData.append('spriteSheetJSON', spriteSheetJSON);
formData.append('expression_dance', expression_dance);
formData.append('expression_emote', expression_emote);
formData.append('expression_sit', expression_sit);
formData.append('expression_stand', expression_stand);
formData.append('expression_transport', expression_transport);
formData.append('preview', preview);
formData.append('spriteSheet', spriteSheet);
formData.append('unityPackage', unityPackage);
await user.uploadAvatarFiles("exampleAvatarId", formData);
Retrieves the data object for a visitor.
OptionalappPublicKey: stringOptionalappJWT: stringOptionalsharedAppPublicKey: stringOptionalsharedAppJWT: stringReturns the data object or an error response.
Increments a specific value in the data object for a visitor by the amount specified. Must have valid interactive credentials from a visitor in the world.
Sets the data object for a visitor.
Updates the data object for a visitor.
Retrieves ids of all dropped assets in all worlds with a matching interactivePublicKey.
Returns the urlSlugs of worlds where the Public Key is found or an error response.
Get expressions
Returns an array of expressions or an error response.
Grant expression to a visitor by id or name.
Returns { success: true } if the expression was granted successfully or an error response.
Grants an inventory item to this visitor.
The InventoryItem to grant to the visitor
The quantity to grant (default: 1)
Returns the granted UserInventoryItem with quantity and metadata.
This method requires that the inventory item is already defined in your application's inventory system. Each visitor can only be granted an item once. Use modifyInventoryItemQuantity() to adjust quantities for items the visitor already owns. The grant_source will be set to track where the item came from.
Important: This method will throw an error if the visitor already owns this inventory item. Check visitorInventoryItems first or use modifyInventoryItemQuantity() to update existing items.
Creates an NPC (Non-Player Character) that follows this visitor using an inventory item the visitor owns.
The ID of the user's inventory item (must be an NPC type item owned by this visitor)
Optionaloptions: { showNameplate?: boolean }Optional configuration for the NPC
OptionalshowNameplate?: booleanWhether to display a nameplate above the NPC (default: true)
Returns a Visitor object representing the created NPC. The NPC will automatically follow the visitor.
One NPC is allowed per visitor, per application public key. NPCs are AI-controlled characters that automatically follow the visitor around the world. They appear as additional avatars and can be useful for companions, guides, or assistant characters.
Requirements:
// First, grant the NPC item to the visitor
const userItem = await visitor.grantInventoryItem(npcInventoryItem, 1);
// Then create the NPC using the granted item
const npc = await visitor.createNpc(userItem.id);
// Or create without a nameplate
const npc = await visitor.createNpc(userItem.id, { showNameplate: false });
Deletes the NPC (Non-Player Character) this app has assigned to this visitor.
Returns nothing if successful.
Retrieves the NPC (Non-Player Character) associated with this visitor, if one exists.
Returns a Visitor object representing the NPC, or null if none exists.
Each visitor can have one NPC per application public key. NPCs are AI-controlled characters that follow the visitor around the world. They are created using inventory items of type "npc" and appear as additional avatars that track the visitor's position. If no NPC exists for this visitor and app, returns null.
OptionaldataReadonlyidOptionaljwtOptionalprofileOptionalprofileOptionaluserStandardized error handler for all SDK operations.
Standardized error object with properties: data, message, method, params, sdkMethod, stack, status, success, url
This method processes errors from API calls and formats them consistently across the SDK. It extracts relevant error information including:
All errors thrown by SDK methods flow through this handler to ensure consistent error format.
Retrieves all inventory items owned by this visitor and app's key.
Returns a new instance of InventoryItem.
Get a single visitor from a world
Returns details for a visitor in a world by id and urlSlug
Display a message via a toast to a visitor currently in a world.
Returns { success: true } or an error.
Modifies the quantity of an inventory item in this visitor's inventory. Supports upsert behavior - if the visitor doesn't own the item yet, it will be granted first.
Either a UserInventoryItem (for owned items) or an InventoryItem (for upsert).
The quantity delta to apply (positive to add, negative to subtract).
Returns the updated inventory item or a response object.
Teleport or walk a visitor currently in a world to a single set of coordinates.
Returns { success: true } if the visitor was moved successfully.
Send an email
Returns { success: true } if the email is sent successfully or an error response.
Setup signal to visitor
Returns the configured Axios instance for making API calls to Topia's Public API.
The configured Axios client instance with authentication headers.
Mute and turn video off for a visitor currently in a world.
Returns { success: true } or an error.
Update analytics for a given public key. Must have valid interactive credentials from a visitor in the world.
Optionalanalytics: AnalyticType[]Get all particles available
Returns an array of particles or an error response.
Trigger a particle effect on a visitor
Returns { success: true } or a message if no particleId is found.
Returns all scenes owned by User.
Retrieves all worlds a user with matching API Key is an admin in, creates a new World object for each, and creates new map of Worlds accessible via user.adminWorlds.
Retrieves all worlds owned by user with matching API Key, creates a new World object for each, and creates new map of Worlds accessible via user.worlds.
{ urlSlug: new World({ apiKey, worldArgs, urlSlug }) }
Close an iframe for a visitor currently in a world.
Returns { success: true } or an error.
Open an iframe in a drawer or modal for a visitor currently in a world.
Returns { success: true } or an error.
Reload an iframe for a visitor currently in a world.
Returns { success: true } or an error.
Create an instance of Visitor class with a given id and optional attributes and session credentials.
Example