InventoryService

From OpenSimulator

(Difference between revisions)
Jump to: navigation, search
(API)
(API)
Line 97: Line 97:
 
     <ID>e3c2a5e8-20c4-4e70-a994-61dae3265b58</ID>
 
     <ID>e3c2a5e8-20c4-4e70-a994-61dae3265b58</ID>
 
   </folder>
 
   </folder>
 +
</ServerResponse>
 +
</source>
 +
 +
If the request fails (e.g. because the PRINCIPAL does not exist) you will receive an empty response
 +
 +
<source lang="xml">
 +
<?xml version="1.0"?><ServerResponse />
 +
</source>
 +
where
 +
 +
* '''ParentID''' is the parent folder ID.  Since this is the root folder this is always UUID.Zero (00000000-0000-0000-0000-000000000000).
 +
* '''Type''' is the type of the folder.  See the InventoryType enum in [https://github.com/openmetaversefoundation/libopenmetaverse/blob/master/OpenMetaverseTypes/Enums.cs libopenmetaverse] for more details.  In this case, the type is 8 (Folder) since this is an ordinary non-system folder.
 +
* '''Version''' is the version of the folder.  This is used for viewer inventory caching purposes.
 +
* '''Name''' is the name of the folder.
 +
* '''Owner''' is the UUID of the avatar that owns the folder (this will always match the PRINCIPAL in our request).
 +
* '''ID''' is the unique id of the folder itself.
 +
 +
=== Sample scripts ===
 +
 +
<source lang="php">
 +
<?php
 +
 +
    $ch = curl_init("http://localhost:8003/xinventory");
 +
   
 +
    curl_setopt($ch, CURLOPT_POST, TRUE);
 +
    curl_setopt($ch, CURLOPT_POSTFIELDS, "ID=e3c2a5e8-20c4-4e70-a994-61dae3265b58&METHOD=GETFOLDER");
 +
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
 +
   
 +
    $result = curl_exec($ch);
 +
    $info = curl_getinfo($ch);
 +
    curl_close($ch);
 +
   
 +
    echo "Return code:" . $info['http_code'] . "\n";
 +
    echo "$result\n";
 +
   
 +
?>
 +
</source>
 +
 +
== GETFOLDERCONTENT ==
 +
 +
This returns the children folders and items of a given inventory folder.  POST field is a urlencoded string like so
 +
 +
PRINCIPAL=efc1b931-20e3-4298-8824-0f891fe3dc59&FOLDER=efc1b932-20e3-4298-8824-0f891fe3dc59&METHOD=GETFOLDERCONTENT
 +
 +
where
 +
 +
* '''METHOD''' is GETFOLDERCONTENT
 +
* '''PRINCIPAL''' is the user that owns the folder.  This is currently mandatory but is really only present for historical reasons.
 +
* '''FOLDER''' is the folder UUID
 +
 +
If successful, example return is
 +
 +
<source lang="xml">
 +
<?xml version="1.0"?>
 +
<ServerResponse>
 +
  <FOLDERS type="List">
 +
    <folder_0 type="List">
 +
      <ParentID>859723cf-6338-497b-ab70-64ca04b64f70</ParentID>
 +
      <Type>-1</Type>
 +
      <Version>1</Version>
 +
      <Name>f1</Name>
 +
      <Owner>efc1b932-20e3-4298-8824-0f891fe3dc59</Owner>
 +
      <ID>4174f4cd-9ff5-8d23-0721-2a758f36f7d0</ID>
 +
    </folder_0>
 +
  </FOLDERS>
 +
  <ITEMS type="List">
 +
    <item_0 type="List">
 +
      <AssetID>31f51766-4a99-4b59-9e53-61f436614c71</AssetID>
 +
      <AssetType>6</AssetType>
 +
      <BasePermissions>581639</BasePermissions>
 +
      <CreationDate>1347487471</CreationDate>
 +
      <CreatorId>efc1b932-20e3-4298-8824-0f891fe3dc59</CreatorId>
 +
      <CreatorData/>
 +
      <CurrentPermissions>581639</CurrentPermissions>
 +
      <Description/>
 +
      <EveryOnePermissions>0</EveryOnePermissions>
 +
      <Flags>0</Flags>
 +
      <Folder>859723cf-6338-497b-ab70-64ca04b64f70</Folder>
 +
      <GroupID>00000000-0000-0000-0000-000000000000</GroupID>
 +
      <GroupOwned>False</GroupOwned>
 +
      <GroupPermissions>0</GroupPermissions>
 +
      <ID>25e16367-accd-4b92-8f46-b55d3f63ad0d</ID>
 +
      <InvType>6</InvType>
 +
      <Name>Primitive</Name>
 +
      <NextPermissions>581632</NextPermissions>
 +
      <Owner>efc1b932-20e3-4298-8824-0f891fe3dc59</Owner>
 +
      <SalePrice>0</SalePrice>
 +
      <SaleType>0</SaleType>
 +
    </item_0>
 +
    <item_1 type="List">
 +
      <AssetID>37f0cbe1-c61f-492b-835b-f9f44b636e37</AssetID>
 +
      <AssetType>6</AssetType>
 +
      <BasePermissions>581633</BasePermissions>
 +
      <CreationDate>1347400903</CreationDate>
 +
      <CreatorId>efc1b932-20e3-4298-8824-0f891fe3dc59</CreatorId>
 +
      <CreatorData/>
 +
      <CurrentPermissions>581633</CurrentPermissions>
 +
      <Description/>
 +
      <EveryOnePermissions>0</EveryOnePermissions>
 +
      <Flags>0</Flags>
 +
      <Folder>859723cf-6338-497b-ab70-64ca04b64f70</Folder>
 +
      <GroupID>00000000-0000-0000-0000-000000000000</GroupID>
 +
      <GroupOwned>False</GroupOwned>
 +
      <GroupPermissions>0</GroupPermissions>
 +
      <ID>dde22b2c-1ae3-40df-8480-7b793544aceb</ID>
 +
      <InvType>6</InvType>
 +
      <Name>Primitive2</Name>
 +
      <NextPermissions>581632</NextPermissions>
 +
      <Owner>efc1b932-20e3-4298-8824-0f891fe3dc59</Owner>
 +
      <SalePrice>0</SalePrice>
 +
      <SaleType>0</SaleType>
 +
    </item_1>
 +
  </ITEMS>
 
</ServerResponse>
 
</ServerResponse>
 
</source>
 
</source>

Revision as of 12:36, 13 September 2012

Contents

Introduction

The OpenSimulator inventory service stores user inventory data (object items, notecard items, folders, etc.) and provides this on request. Note that every inventory item points towards an immutable asset entry that actually contains the data.

The current default ROBUST OpenSimulator inventory service is known as the XInventoryService.

API

General notes

Unlike the asset service, the xinventory service is an RPC interface. Therefore it exposes only one URI which is xinventory (e.g. http://localhost:8003/xinventory). The invocation of different operations (e.g. add item, get item) is controlled via a METHOD parameter.

GETROOTFOLDER

This returns data about a user's root folder (i.e. their "My Inventory" folder"). POST field is a urlencoded string like so

PRINCIPAL=efc1b932-20e3-4298-8824-0f891fe3dc59&METHOD=GETROOTFOLDER

where

  • METHOD is GETROOTFOLDER
  • PRINCIPAL is the UUID of the user

If successful, example return is

<?xml version="1.0"?>
<ServerResponse>
  <folder type="List">
    <ParentID>00000000-0000-0000-0000-000000000000</ParentID>
    <Type>9</Type>
    <Version>1</Version>
    <Name>My Inventory</Name>
    <Owner>efc1b932-20e3-4298-8824-0f891fe3dc59</Owner>
    <ID>035f457b-a0f6-4580-a10c-e4f908e176ac</ID>
  </folder>
</ServerResponse>

If the request fails (e.g. because the PRINCIPAL does not exist) you will receive an empty response

<?xml version="1.0"?><ServerResponse />

where

  • ParentID is the parent folder ID. Since this is the root folder this is always UUID.Zero (00000000-0000-0000-0000-000000000000).
  • Type is the type of the folder. See the InventoryType enum in libopenmetaverse for more details. In this case, the type will always be 9 (RootCategory) since this is the root folder.
  • Version is the version of the folder. This is used for viewer inventory caching purposes.
  • Name is the name of the folder.
  • Owner is the UUID of the avatar that owns the folder (this will always match the PRINCIPAL in our request).
  • ID is the unique id of the folder itself.

Sample scripts

<?php
 
    $ch = curl_init("http://localhost:8003/xinventory");
 
    curl_setopt($ch, CURLOPT_POST, TRUE);
    curl_setopt($ch, CURLOPT_POSTFIELDS, "PRINCIPAL=efc1b931-20e3-4298-8824-0f891fe3dc59&METHOD=GETROOTFOLDER");
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
 
    $result = curl_exec($ch);
    $info = curl_getinfo($ch);
    curl_close($ch);
 
    echo "Return code:" . $info['http_code'] . "\n";
    echo "$result\n";
 
?>

GETFOLDER

This returns data about a particular inventory folder. POST field is a urlencoded string like so

ID=efc1b932-20e3-4298-8824-0f891fe3dc59&METHOD=GETFOLDER

where

  • METHOD is GETFOLDER
  • ID is the folder UUID

If successful, example return is

<?xml version="1.0"?>
<ServerResponse>
  <folder type="List">
    <ParentID>035f457b-a0f6-4580-a10c-e4f908e176ac</ParentID>
    <Type>8</Type>
    <Version>1</Version>
    <Name>Some folder</Name>
    <Owner>efc1b932-20e3-4298-8824-0f891fe3dc59</Owner>
    <ID>e3c2a5e8-20c4-4e70-a994-61dae3265b58</ID>
  </folder>
</ServerResponse>

If the request fails (e.g. because the PRINCIPAL does not exist) you will receive an empty response

<?xml version="1.0"?><ServerResponse />

where

  • ParentID is the parent folder ID. Since this is the root folder this is always UUID.Zero (00000000-0000-0000-0000-000000000000).
  • Type is the type of the folder. See the InventoryType enum in libopenmetaverse for more details. In this case, the type is 8 (Folder) since this is an ordinary non-system folder.
  • Version is the version of the folder. This is used for viewer inventory caching purposes.
  • Name is the name of the folder.
  • Owner is the UUID of the avatar that owns the folder (this will always match the PRINCIPAL in our request).
  • ID is the unique id of the folder itself.

Sample scripts

<?php
 
    $ch = curl_init("http://localhost:8003/xinventory");
 
    curl_setopt($ch, CURLOPT_POST, TRUE);
    curl_setopt($ch, CURLOPT_POSTFIELDS, "ID=e3c2a5e8-20c4-4e70-a994-61dae3265b58&METHOD=GETFOLDER");
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
 
    $result = curl_exec($ch);
    $info = curl_getinfo($ch);
    curl_close($ch);
 
    echo "Return code:" . $info['http_code'] . "\n";
    echo "$result\n";
 
?>

GETFOLDERCONTENT

This returns the children folders and items of a given inventory folder. POST field is a urlencoded string like so

PRINCIPAL=efc1b931-20e3-4298-8824-0f891fe3dc59&FOLDER=efc1b932-20e3-4298-8824-0f891fe3dc59&METHOD=GETFOLDERCONTENT

where

  • METHOD is GETFOLDERCONTENT
  • PRINCIPAL is the user that owns the folder. This is currently mandatory but is really only present for historical reasons.
  • FOLDER is the folder UUID

If successful, example return is

<?xml version="1.0"?>
<ServerResponse>
  <FOLDERS type="List">
    <folder_0 type="List">
      <ParentID>859723cf-6338-497b-ab70-64ca04b64f70</ParentID>
      <Type>-1</Type>
      <Version>1</Version>
      <Name>f1</Name>
      <Owner>efc1b932-20e3-4298-8824-0f891fe3dc59</Owner>
      <ID>4174f4cd-9ff5-8d23-0721-2a758f36f7d0</ID>
    </folder_0>
  </FOLDERS>
  <ITEMS type="List">
    <item_0 type="List">
      <AssetID>31f51766-4a99-4b59-9e53-61f436614c71</AssetID>
      <AssetType>6</AssetType>
      <BasePermissions>581639</BasePermissions>
      <CreationDate>1347487471</CreationDate>
      <CreatorId>efc1b932-20e3-4298-8824-0f891fe3dc59</CreatorId>
      <CreatorData/>
      <CurrentPermissions>581639</CurrentPermissions>
      <Description/>
      <EveryOnePermissions>0</EveryOnePermissions>
      <Flags>0</Flags>
      <Folder>859723cf-6338-497b-ab70-64ca04b64f70</Folder>
      <GroupID>00000000-0000-0000-0000-000000000000</GroupID>
      <GroupOwned>False</GroupOwned>
      <GroupPermissions>0</GroupPermissions>
      <ID>25e16367-accd-4b92-8f46-b55d3f63ad0d</ID>
      <InvType>6</InvType>
      <Name>Primitive</Name>
      <NextPermissions>581632</NextPermissions>
      <Owner>efc1b932-20e3-4298-8824-0f891fe3dc59</Owner>
      <SalePrice>0</SalePrice>
      <SaleType>0</SaleType>
    </item_0>
    <item_1 type="List">
      <AssetID>37f0cbe1-c61f-492b-835b-f9f44b636e37</AssetID>
      <AssetType>6</AssetType>
      <BasePermissions>581633</BasePermissions>
      <CreationDate>1347400903</CreationDate>
      <CreatorId>efc1b932-20e3-4298-8824-0f891fe3dc59</CreatorId>
      <CreatorData/>
      <CurrentPermissions>581633</CurrentPermissions>
      <Description/>
      <EveryOnePermissions>0</EveryOnePermissions>
      <Flags>0</Flags>
      <Folder>859723cf-6338-497b-ab70-64ca04b64f70</Folder>
      <GroupID>00000000-0000-0000-0000-000000000000</GroupID>
      <GroupOwned>False</GroupOwned>
      <GroupPermissions>0</GroupPermissions>
      <ID>dde22b2c-1ae3-40df-8480-7b793544aceb</ID>
      <InvType>6</InvType>
      <Name>Primitive2</Name>
      <NextPermissions>581632</NextPermissions>
      <Owner>efc1b932-20e3-4298-8824-0f891fe3dc59</Owner>
      <SalePrice>0</SalePrice>
      <SaleType>0</SaleType>
    </item_1>
  </ITEMS>
</ServerResponse>

If the request fails (e.g. because the PRINCIPAL does not exist) you will receive an empty response

<?xml version="1.0"?><ServerResponse />

where

  • ParentID is the parent folder ID. Since this is the root folder this is always UUID.Zero (00000000-0000-0000-0000-000000000000).
  • Type is the type of the folder. See the InventoryType enum in libopenmetaverse for more details. In this case, the type is 8 (Folder) since this is an ordinary non-system folder.
  • Version is the version of the folder. This is used for viewer inventory caching purposes.
  • Name is the name of the folder.
  • Owner is the UUID of the avatar that owns the folder (this will always match the PRINCIPAL in our request).
  • ID is the unique id of the folder itself.

Sample scripts

<?php
 
    $ch = curl_init("http://localhost:8003/xinventory");
 
    curl_setopt($ch, CURLOPT_POST, TRUE);
    curl_setopt($ch, CURLOPT_POSTFIELDS, "ID=e3c2a5e8-20c4-4e70-a994-61dae3265b58&METHOD=GETFOLDER");
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
 
    $result = curl_exec($ch);
    $info = curl_getinfo($ch);
    curl_close($ch);
 
    echo "Return code:" . $info['http_code'] . "\n";
    echo "$result\n";
 
?>
Personal tools
General
About This Wiki