Get page by URL
In this example, we demonstrate how to retrieve a single CMS page by its URL identifier using the OneEntry API.
✅ Purpose of the scenario:
- Connect to the OneEntry API
- Retrieve a page by its URL identifier
- Access page content via localizeInfos and attributeValues
✅ What you need:
- A valid PROJECT_URL and APP_TOKEN for authentication with the OneEntry API.
- A page configured in OneEntry with a known URL (e.g., "home_web")
📌 Important:
- 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 page by URL — In this example, we demonstrate how to retrieve a single CMS page by its URL identifier using the OneEntry API.
Scenario
1. Import defineOneEntry from SDK and define PROJECT_URL and APP_TOKEN
Example:
import { defineOneEntry } from 'oneentry';
const PROJECT_URL = 'your-project-url';
const APP_TOKEN = 'your-app-token';
2. Creating an API client with defineOneEntry()
Example:
const { Pages } = defineOneEntry(PROJECT_URL, {
token: APP_TOKEN,
});
3. Get page by URL with Pages.getPageByUrl()
Example:
const page = await Pages.getPageByUrl('home_web');
console.log('Page: ', page);
Result:
{
"id": 9,
"parentId": null,
"pageUrl": "home_web",
"depth": 0,
"localizeInfos": {
"title": "Home web",
"menuTitle": "Home web",
"htmlContent": "",
"plainContent": ""
},
"isVisible": true,
"blocks": [],
"type": "common_page",
"templateIdentifier": null,
"attributeSetIdentifier": null,
"attributeValues": {},
"moduleFormConfigs": [],
"isSync": false
}
Final example
// 1. Import defineOneEntry from SDK and define PROJECT_URL and APP_TOKEN
import { defineOneEntry } from 'oneentry';
const PROJECT_URL = 'your-project-url';
const APP_TOKEN = 'your-app-token';
// 2. Creating an API client with [defineOneEntry()](/docs/index/#Installation)
const { Pages } = defineOneEntry(PROJECT_URL, {
token: APP_TOKEN,
});
// 3. Get page by URL with [Pages.getPageByUrl()](/docs/pages/getPageByUrl)
const page = await Pages.getPageByUrl('home_web');
console.log('Page: ', page);