Skip to main content

Get products by page URL

Fetches all products that belong to a catalog page.

What this example does:

  • Connects to the OneEntry API
  • Retrieves products filtered by their catalog page URL
  • Reviews the returned products list

Prerequisites:

  • A valid PROJECT_URL and APP_TOKEN for the OneEntry API
  • A catalog page configured in OneEntry with a known URL (e.g., "products")
  • Products assigned to that catalog page

Notes:

  • Returns { items, total }, not a plain array.
  • The url parameter must match the pageUrl of a catalog_page type page.
  • By default (isShell: true) the SDK returns an error object instead of throwing, so check the result, e.g. 'statusCode' in result. With isShell: false it throws, and you handle errors with try/catch. See Errors.

Platform docs:

SDK reference:

Try it live​

Run this example in the JS SDK sandbox. Connect your Project URL and App Token on first visit, then open:

Scenario​

1. Import defineOneEntry and define PROJECT_URL and APP_TOKEN​

import { defineOneEntry } from 'oneentry';
import type { IProductsQueryBase } from 'oneentry';

const PROJECT_URL = 'https://your-project.oneentry.cloud';
const APP_TOKEN = 'your-app-token';

2. Create an API client with defineOneEntry()​

const { Products } = defineOneEntry(PROJECT_URL, {
token: APP_TOKEN,
});

3. Define request parameters​

const userQuery: IProductsQueryBase = {
offset: 0,
limit: 20,
sortKey: 'price',
sortOrder: 'ASC',
};

4. Get products by page URL with Products.getProductsByPageUrl()​

const data = await Products.getProductsByPageUrl('products', [], 'en_US', userQuery);

if ('statusCode' in data) {
throw new Error(data.message);
}

console.log('Products: ', data.items);
console.log('Total: ', data.total);
Result:
{
"items": [
{
"id": 13,
"attributeSetIdentifier": "product",
"localizeInfos": {
"title": "Red ball"
},
"statusLocalizeInfos": {},
"isVisible": true,
"statusIdentifier": null,
"position": 1,
"templateIdentifier": null,
"shortDescTemplateIdentifier": null,
"price": 300,
"additional": {
"prices": {
"min": 100,
"max": 999
}
},
"sku": null,
"isSync": true,
"categories": [
"products"
],
"paymentStages": null,
"rating": {},
"isPositionLocked": false,
"attributeValues": {
"price": {
"type": "real",
"value": "300",
"isIcon": false,
"position": 0,
"additionalFields": {},
"isProductPreview": false
},
"currency": {
"type": "string",
"value": "USD",
"isIcon": false,
"position": 1,
"additionalFields": {},
"isProductPreview": false
},
"image": {
"type": "image",
"value": [],
"isIcon": false,
"position": 2,
"additionalFields": {},
"isProductPreview": true
}
},
"moduleFormConfigs": [],
"discountConfig": {}
},
{
"id": 14,
"attributeSetIdentifier": "product",
"localizeInfos": {
"title": "Green ball"
},
"statusLocalizeInfos": {},
"isVisible": true,
"statusIdentifier": null,
"position": 2,
"templateIdentifier": null,
"shortDescTemplateIdentifier": null,
"price": 340,
"additional": {
"prices": {
"min": 100,
"max": 999
}
},
"sku": null,
"isSync": true,
"categories": [
"products"
],
"paymentStages": null,
"rating": {},
"isPositionLocked": false,
"attributeValues": {
"price": {
"type": "real",
"value": "340",
"isIcon": false,
"position": 0,
"additionalFields": {},
"isProductPreview": false
},
"currency": {
"type": "string",
"value": "USD",
"isIcon": false,
"position": 1,
"additionalFields": {},
"isProductPreview": false
},
"image": {
"type": "image",
"value": [],
"isIcon": false,
"position": 2,
"additionalFields": {},
"isProductPreview": true
}
},
"moduleFormConfigs": [],
"discountConfig": {}
},
{
"id": 15,
"attributeSetIdentifier": "product",
"localizeInfos": {
"title": "Orange ball"
},
"statusLocalizeInfos": {},
"isVisible": true,
"statusIdentifier": null,
"position": 3,
"templateIdentifier": null,
"shortDescTemplateIdentifier": null,
"price": 400,
"additional": {
"prices": {
"min": 100,
"max": 999
}
},
"sku": null,
"isSync": true,
"categories": [
"products"
],
"paymentStages": null,
"rating": {},
"isPositionLocked": false,
"attributeValues": {
"price": {
"type": "real",
"value": "400",
"isIcon": false,
"position": 0,
"additionalFields": {},
"isProductPreview": false
},
"currency": {
"type": "string",
"value": "USD",
"isIcon": false,
"position": 1,
"additionalFields": {},
"isProductPreview": false
},
"image": {
"type": "image",
"value": [],
"isIcon": false,
"position": 2,
"additionalFields": {},
"isProductPreview": true
}
},
"moduleFormConfigs": [],
"discountConfig": {}
}
],
"total": 3
}

Final example​

// 1. Import defineOneEntry and define PROJECT_URL and APP_TOKEN
import { defineOneEntry } from 'oneentry';
import type { IProductsQueryBase } from 'oneentry';

const PROJECT_URL = 'https://your-project.oneentry.cloud';
const APP_TOKEN = 'your-app-token';

// 2. Create an API client with defineOneEntry()
const { Products } = defineOneEntry(PROJECT_URL, {
token: APP_TOKEN,
});

// 3. Define request parameters
const userQuery: IProductsQueryBase = {
offset: 0,
limit: 20,
sortKey: 'price',
sortOrder: 'ASC',
};

// 4. Get products by page URL with Products.getProductsByPageUrl()
const data = await Products.getProductsByPageUrl('products', [], 'en_US', userQuery);

if ('statusCode' in data) {
throw new Error(data.message);
}

console.log('Products: ', data.items);
console.log('Total: ', data.total);