{"__v":1,"_id":"570a624742cbb61700228c98","category":{"project":"56abbf55f25f160d00e17f4e","version":"56abbf55f25f160d00e17f51","_id":"570a5676ade45d0e00c1ad33","__v":0,"sync":{"url":"","isSync":false},"reference":true,"createdAt":"2016-04-10T13:34:46.864Z","from_sync":false,"order":3,"slug":"client-side-api","title":"Client Side API"},"parentDoc":null,"project":"56abbf55f25f160d00e17f4e","user":"56abbec30b9e0b0d00616274","version":{"__v":12,"_id":"56abbf55f25f160d00e17f51","project":"56abbf55f25f160d00e17f4e","createdAt":"2016-01-29T19:36:53.665Z","releaseDate":"2016-01-29T19:36:53.665Z","categories":["56abbf56f25f160d00e17f52","56abca6bf9757e0d007c6650","56acddfa0ab3c00d00ce3332","56af65da9d32e30d0006d30f","56af66cab34d210d003d9ad0","56af6afcd21e9c0d00b628d1","56af6d6ecc4cbd0d00ce2c88","5705b12221cfed0e00e8c580","570a5676ade45d0e00c1ad33","570d7d25d1e4b82000d9e385","570eac3c3160d10e0041df0e","575709000fd6a3200010dded"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"","version_clean":"1.0.0","version":"1.0"},"updates":[],"next":{"pages":[],"description":""},"createdAt":"2016-04-10T14:25:11.297Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","auth":"required","params":[],"url":""},"isReference":true,"order":10,"body":"## Requesting Item Definitions\n\nThe 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:\n[block:parameters]\n{\n  \"data\": {\n    \"h-0\": \"Name\",\n    \"h-1\": \"Type\",\n    \"h-2\": \"Description\",\n    \"0-0\": \"`tags`\",\n    \"0-1\": \"Array\",\n    \"0-2\": \"An array of strings containing tags to filter items with. Use an empty array or `undefined` for no filter\",\n    \"1-0\": \"`callback`\",\n    \"1-1\": \"Function\",\n    \"1-2\": \"A callback function to be called with the results of the operation\"\n  },\n  \"cols\": 3,\n  \"rows\": 2\n}\n[/block]\nThe callback function is passed a single object with the following fields:\n[block:parameters]\n{\n  \"data\": {\n    \"h-0\": \"Name\",\n    \"h-1\": \"Type\",\n    \"h-2\": \"Description\",\n    \"0-0\": \"`success`\",\n    \"0-1\": \"Boolean\",\n    \"0-2\": \"A flag indicating whether or not the operation was successful\",\n    \"1-0\": \"`data`\",\n    \"1-1\": \"Array\",\n    \"1-2\": \"An array of item definitions, if successful\"\n  },\n  \"cols\": 3,\n  \"rows\": 2\n}\n[/block]\nEach item definition in the `data` array contains the following fields:\n[block:parameters]\n{\n  \"data\": {\n    \"h-0\": \"Name\",\n    \"h-1\": \"Type\",\n    \"h-2\": \"Description\",\n    \"0-0\": \"`id`\",\n    \"0-1\": \"Integer\",\n    \"0-2\": \"The unique ID of the item\",\n    \"1-0\": \"`identifier`\",\n    \"1-1\": \"String\",\n    \"1-2\": \"The item identifier\",\n    \"2-0\": \"`name`\",\n    \"2-1\": \"String\",\n    \"2-2\": \"The name of the item\",\n    \"3-0\": \"`description`\",\n    \"3-1\": \"String\",\n    \"3-2\": \"The item description\",\n    \"4-0\": \"`price`\",\n    \"4-1\": \"Integer\",\n    \"4-2\": \"The price of the item in Kreds\",\n    \"5-0\": \"`tags`\",\n    \"5-1\": \"Array\",\n    \"5-2\": \"An array of strings containing the tags for the item\",\n    \"6-0\": \"`image_url`\",\n    \"6-1\": \"String\",\n    \"6-2\": \"The image for the item\"\n  },\n  \"cols\": 3,\n  \"rows\": 7\n}\n[/block]\n**Example:** Request all items:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"kongregate.mtx.requestItemList([], onItemList);\\n\\nfunction onItemList(result:Object):void{\\n  trace(\\\"Item list result, success: \\\" + result.success);\\n  if(result.success) {\\n    for(var i:int = 0; i < result.data.length; i++) {\\n      var item:Object = result.data[i];\\n      trace((i+1) + \\\". \\\" + item.identifier + \\\", \\\" + item.id + \\\",\\\" + item.name);\\n    }\\n  }\\n}\",\n      \"language\": \"haxe\",\n      \"name\": \"ActionScript 3\"\n    },\n    {\n      \"code\": \"kongregate.mtx.requestItemList([], onItemList);\\n\\nfunction onItemList(result){\\n  console.log(\\\"Item list result, success: \\\" + result.success);\\n  if(result.success) {\\n    for(var i = 0; i < result.data.length; i++) {\\n      var item = result.data[i];\\n      console.log((i+1) + \\\". \\\" + item.identifier + \\\", \\\" + \\n                  item.id + \\\",\\\" + item.name);\\n    }\\n  }\\n}\",\n      \"language\": \"javascript\"\n    }\n  ]\n}\n[/block]","excerpt":"Request item definitions from the server\n`requestItemList(tags, callback)`","slug":"client-api-mtx-requestitemlist","type":"fn","title":"Mtx.RequestItemList"}

fnMtx.RequestItemList

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: [block:parameters] { "data": { "h-0": "Name", "h-1": "Type", "h-2": "Description", "0-0": "`tags`", "0-1": "Array", "0-2": "An array of strings containing tags to filter items with. Use an empty array or `undefined` for no filter", "1-0": "`callback`", "1-1": "Function", "1-2": "A callback function to be called with the results of the operation" }, "cols": 3, "rows": 2 } [/block] The callback function is passed a single object with the following fields: [block:parameters] { "data": { "h-0": "Name", "h-1": "Type", "h-2": "Description", "0-0": "`success`", "0-1": "Boolean", "0-2": "A flag indicating whether or not the operation was successful", "1-0": "`data`", "1-1": "Array", "1-2": "An array of item definitions, if successful" }, "cols": 3, "rows": 2 } [/block] Each item definition in the `data` array contains the following fields: [block:parameters] { "data": { "h-0": "Name", "h-1": "Type", "h-2": "Description", "0-0": "`id`", "0-1": "Integer", "0-2": "The unique ID of the item", "1-0": "`identifier`", "1-1": "String", "1-2": "The item identifier", "2-0": "`name`", "2-1": "String", "2-2": "The name of the item", "3-0": "`description`", "3-1": "String", "3-2": "The item description", "4-0": "`price`", "4-1": "Integer", "4-2": "The price of the item in Kreds", "5-0": "`tags`", "5-1": "Array", "5-2": "An array of strings containing the tags for the item", "6-0": "`image_url`", "6-1": "String", "6-2": "The image for the item" }, "cols": 3, "rows": 7 } [/block] **Example:** Request all items: [block:code] { "codes": [ { "code": "kongregate.mtx.requestItemList([], onItemList);\n\nfunction onItemList(result:Object):void{\n trace(\"Item list result, success: \" + result.success);\n if(result.success) {\n for(var i:int = 0; i < result.data.length; i++) {\n var item:Object = result.data[i];\n trace((i+1) + \". \" + item.identifier + \", \" + item.id + \",\" + item.name);\n }\n }\n}", "language": "haxe", "name": "ActionScript 3" }, { "code": "kongregate.mtx.requestItemList([], onItemList);\n\nfunction onItemList(result){\n console.log(\"Item list result, success: \" + result.success);\n if(result.success) {\n for(var i = 0; i < result.data.length; i++) {\n var item = result.data[i];\n console.log((i+1) + \". \" + item.identifier + \", \" + \n item.id + \",\" + item.name);\n }\n }\n}", "language": "javascript" } ] } [/block]