Request item definitions from the server
requestItemList(tags, callback)

Requesting Item Definitions

The non-dynamic item definitions for a game can be retrieved using the requestItemList method. This function takes an array of tags to filter on (pass an empty array for all items), and a callback function to call when retrieval is complete:

Name

Type

Description

tags

Array

An array of strings containing tags to filter items with. Use an empty array or undefined for no filter

callback

Function

A callback function to be called with the results of the operation

The callback function is passed a single object with the following fields:

Name

Type

Description

success

Boolean

A flag indicating whether or not the operation was successful

data

Array

An array of item definitions, if successful

Each item definition in the data array contains the following fields:

Name

Type

Description

id

Integer

The unique ID of the item

identifier

String

The item identifier

name

String

The name of the item

description

String

The item description

price

Integer

The price of the item in Kreds

tags

Array

An array of strings containing the tags for the item

image_url

String

The image for the item

Example: Request all items:

kongregate.mtx.requestItemList([], onItemList);

function onItemList(result:Object):void{
  trace("Item list result, 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.name);
    }
  }
}
kongregate.mtx.requestItemList([], onItemList);

function onItemList(result){
  console.log("Item list result, success: " + result.success);
  if(result.success) {
    for(var i = 0; i < result.data.length; i++) {
      var item = result.data[i];
      console.log((i+1) + ". " + item.identifier + ", " + 
                  item.id + "," + item.name);
    }
  }
}