Linden Lab Official:Inventory API

From Second Life Wiki
Jump to navigation Jump to search


Inventory API

This document uses LLIDL for terse description of the HTTP POST and response bodies.

Viewer Capabilities

The Viewer receives four Inventory API capabilities. A fifth one, FetchInventoryDescendents, is deprecated by WebFetchInventoryDescendents.

Note well: descendants is frequently but haphazardly misspelled as descendents in the code. Sadly, these misspellings are fixed in place due to existing widespread deployment.

WebFetchInventoryDescendents

Follows the Fetch Inventory Descendents API, fetches the agent's inventory structure.

FetchInventory

Follows the Fetch Inventory Items API, fetches the agent's items.

FetchLibDescendents

Follows the Fetch Inventory Descendents API, fetches library inventory structure.

FetchLib

Follows the Fetch Inventory Items API, fetches library inventory items.

Structures

<python>

&category = {
   agent_id        : uuid,
   category_id     : uuid,
   parent_id       : uuid,
   name            : string,
   type_default    : int,
   version         : int,
}

&item = {
   agent_id        : uuid,
   item_id         : uuid,
   parent_id       : uuid,  (category_id of the containing folder)
   asset_id        : uuid,  (available only for downloadable assets)
   name            : string,
   desc            : string,
   created_at      : int,   (timestamp)
   type            : int,   (asset type)
   inv_type        : int,   (inventory type)
   flags           : int,   (type-specific flags)
   permissions     : &permissions,
   sale_info       : &sale_info,
}

&permissions = {
   creator_id      : uuid,
   owner_id        : uuid,   (always same as agent_id)
   group_id        : uuid,
   last_owner_id   : uuid,
   is_owner_group  : bool,
   base_mask       : int,
   group_mask      : int,
   owner_mask      : int,
   next_owner_mask : int,
   everyone_mask   : int,
}

&sale_info = {
   sale_price      : int,
   sale_type       : int,
}

</python>

Links

Item Links

Item links have inventory_type 24. The asset_id field of the item points to an item_id. When the parent category contents are retrieved, both the link item and the link target appear in the listing. Viewer must resolve the links by using the target item's information and removing the target item from the listing. Broken links, that is, a link item for which there is no corresponding target item, must be shown as broken links, allowing the user to take corrective action.

Folder Links

Folder links are represented by items with inventory_type 25. The asset_id field of the item points to a category_id. Viewers should enable viewing of the contents of the target category, while indicating that the category is a link.

APIs

Fetch Inventory Items

<python>

%% FetchInventoryCapURL
-> { items: [{ item_id: uuid }, ... ] }
<- { agent_id: uuid, items: [ &item, ... ] }

</python>

Fetch Inventory Descendents

<python>

%% FetchInventoryDescendentsCapURL
-> { folders: [{ folder_id: uuid }, ... ] }
<- { folders: [{ agent_id: uuid,
                 owner_id: uuid,
                 folder_id: uuid,
                 version: int,
                 descendents: int,                 (len(items) + len(categories))
                 categories: [ &category, ... ],
                 items: [ &item, ... ]
              }] }

</python>