Linden Lab Official:Inventory API

From Second Life Wiki
Jump to navigation Jump to search

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: 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.

API

Fetch Inventory Items

Returns information on the specified inventory items.

HTTP method: POST

Path:

AIS_base/agent/agent_id/inventory/fetch

Parameters

Query (POST) parameters:

  • items - a map with one key, 'items', whose value is an array of maps, each with one key, 'item_id', whose value is the item you want information about.

Return value

The response is a map containing two keys, as shown in the following table.

Key Datatype Description
agent_id UUID UUID of the agent in question
items array Array of item data structures.

Each item data structure is a map with the following elements:

Return value Datatype Description
agent_id UUID
asset_id UUID
created_at int timestamp?
desc string
flags integer
inv_type integer same as asset type?
item_id UUID
name string
parent_id UUID
permissions Map containing Permissions
sale_info Map containing Sale info
type integer asset type

Example

TBD

LLIDL

<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>

Using HTTP POST, send a body containing a map with one key, 'folders', whose value is an array of maps, each with one key, 'folder_id', each of whose value is the category you want information about.

The response will be a map containing one key, 'folders', whose value is an array of folder structures with bonus descendents information.