--- title: "getXgenPredictions()" slug: "getxgenpredictions" updated: 2024-06-13T14:01:25Z published: 2024-06-13T14:01:25Z canonical: "docs.xgen.ai/getxgenpredictions" --- > ## Documentation Index > Fetch the complete documentation index at: https://docs.xgen.ai/llms.txt > Use this file to discover all available pages before exploring further. # getXgenPredictions() `getXgenPredictions()` is used to retrieve multiple sets of XGen’s personalized recommendation predictions. These predictions are used for rendering out personalized elements unique to each user. This function calls multiple elements. For a simpler syntax when calling a single element, use [getXGenPrediction()](/v1/docs/getxgenprediction). > If the pages functionality is being used, this function will wait for a page to be matched before the promise resolves. #### Syntax ```javascript getXgenPredictions(elementIds); getXgenPredictions(elementId1, /* …, */ elementIdN); ``` #### Parameters `elementIds` **type:** `array` **description:** An array of the element IDs that will be returned from this function. **items:** `elementId` **type:** `string` **description:** The ID of an XGen element. Can be accessed from the XGen platform under ‘Site Personalization.’ `elementId1 … elementIdN` **type:** `string` **description:** Element IDs that will be returned from this function that are passed in as separate parameters > As an alternative to passing in an array of element IDs, you can pass in each element ID as its own parameter and the functionality and output will be the same. #### Return Value A `promise` that resolves with an `object` in which the keys are element IDs and the values are an array of objects containing product information. Example: ![](https://cdn.us.document360.io/ae46ce4b-af2c-4789-b3ad-1d1ccd16b4a1/Images/Documentation/image(6).png) #### Examples ##### Get list of elements with array syntax: In this example, we get elements by passing in an array of element IDs. When the returned promise resolves, we console log the `prod_code` (aka `product ID`) of each product recommended. ```javascript // Create integration (use existing integration if you already created one) const integration = new XG(...config); // Get two elements from prediction API const predictions = await integration.getXgenPredictions([  'sm_el_b04ebc323ccb4f49bedcece7652e4fba',  'sm_el_4784cbbec2794c87a4d40a87881d8ce0' ]); // Get products from first element const products = predictions['sm_el_b04ebc323ccb4f49bedcece7652e4fba']; // Console log prod_code of each product recommended products.forEach(product => console.log(product.prod_code)); ``` ##### Get list of elements with multiple parameter syntax: In this example, we get elements by passing in each element ID as its own parameter. When the returned promise resolves, we console log the prod_code (aka product ID) of each product recommended. ```javascript // Create integration (use existing integration if you already created one) const integration = new XG(...config); // Get two elements from prediction API const predictions = await integration.getXgenPredictions(  'sm_el_b04ebc323ccb4f49bedcece7652e4fba',  'sm_el_4784cbbec2794c87a4d40a87881d8ce0' ); // Get products from first element const products = predictions['sm_el_b04ebc323ccb4f49bedcece7652e4fba']; // Console log prod_code of each product recommended products.forEach(product => console.log(product.prod_code)); ```