Skip to main content

Get products by page URL

In this example, we demonstrate how to retrieve all products belonging to a specific catalog page using the OneEntry API.

✅ Purpose of the scenario:

  • Connect to the OneEntry API
  • Retrieve products filtered by their catalog page URL
  • Review the returned products list

✅ What you need:

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

📌 Important:

  • Returns { items, total } — not a plain array.
  • The url parameter must match the pageUrl of a catalog_page type page.
  • These examples do not include error handling.
  • You can manage errors using a try-catch block or by employing a construction like await Promise.catch((error) => error).

📚 See in documentation:

📦 SDK reference:

Try it live

Run this method interactively in the JS SDK sandbox — connect your Project URL and App Token on first visit, then open:

  • Get products by page URL — In this example, we demonstrate how to retrieve all products belonging to a specific catalog page using the OneEntry API.

Scenario

1. Import defineOneEntry from SDK and define PROJECT_URL and APP_TOKEN

Example:

import { defineOneEntry } from 'oneentry';
import type { IProductsQuery } from 'oneentry/dist/products/productsInterfaces';

const PROJECT_URL = 'your-project-url';
const APP_TOKEN = 'your-app-token';

2. Creating an API client with defineOneEntry()

Example:

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

3. Define request parameters

Example:

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

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

Example:

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 from SDK and define PROJECT_URL and APP_TOKEN
import { defineOneEntry } from 'oneentry';
import type { IProductsQuery } from 'oneentry/dist/products/productsInterfaces';

const PROJECT_URL = 'your-project-url';
const APP_TOKEN = 'your-app-token';

// 2. Creating an API client with [defineOneEntry()](/docs/index/#Installation)
const { Products } = defineOneEntry(PROJECT_URL, {
token: APP_TOKEN,
});

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

// 4. Get products by page URL with [Products.getProductsByPageUrl()](/docs/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);