Kongregate Developers

Requesting User Item Instances

The inventory of any user can be requested by using the requestUserItemList method. This function takes a username string as the first argument, but you may pass in null or a blank string to request the inventory for the current user. The second argument is a callback function to call when retrieval is complete, which will usually involve a call to use_item.

  • username:String - The username to request inventory for, or null for the current player.
  • callback:Function - The callback function

response if successful:

  • success:Boolean - True if successful
  • data:Array - List of item instance Objects (if successful):
    • id:Number - Database ID of the item instance
    • identifier:String - Item identifier string
    • data:String - Item metadata (attached at checkout time)
    • remaining_uses:Number - Number of uses remaining

Example: Request the inventory for the current player

// Request the inventory for the current player
kongregate.mtx.requestUserItemList(null, onUserItems);

// The callback function
function onUserItems(result:Object):void{
  trace("User item list received, success: " + result.success);
  if( result.success ){
    for( var i:int = 0; i < result.data.length; i++ ){
      var item:Object = result.data[i];
      trace((i+1) + ". " + item.identifier + ", " + item.id + "," + item.data);