Get attributes by marker
In this example, we demonstrate how to retrieve the attribute schema for a specific attribute set by its marker using the OneEntry API.
✅ Purpose of the scenario:
- Connect to the OneEntry API
- Retrieve the attribute schema for a named attribute set
- Access attribute metadata: marker, type, label, validators, and listTitles
✅ What you need:
- A valid PROJECT_URL and APP_TOKEN for authentication with the OneEntry API.
- An attribute set configured in OneEntry with a known marker (e.g., "product")
📌 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).
- Returns SCHEMA of attributes — NOT the actual values of entities.
- value is always in schema — to get real values use Products.getProducts(), Pages.getPageByUrl(), etc.
- Use listTitles to build filter options for list and radioButton type attributes.
📚 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 attributes by marker — In this example, we demonstrate how to retrieve the attribute schema for a specific attribute set by its marker 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 { AttributesSets } = defineOneEntry(PROJECT_URL, {
token: APP_TOKEN,
});
3. Get attribute schema by marker with AttributesSets.getAttributesByMarker()
Example:
const attributes = await AttributesSets.getAttributesByMarker(
'product',
'en_US',
);
console.log('Attributes: ', attributes);
Result:
[
{
"type": "real",
"value": {},
"marker": "price",
"position": 1,
"listTitles": [],
"validators": {
"requiredValidator": {
"strict": true
}
},
"initialValue": null,
"localizeInfos": {
"title": "Price"
},
"additionalFields": {}
},
{
"type": "string",
"value": {},
"marker": "currency",
"position": 2,
"listTitles": [],
"validators": {
"defaultValueValidator": {
"fieldDefaultValue": "USD",
"fieldDefaultValue2": ""
}
},
"initialValue": null,
"localizeInfos": {
"title": "Currency"
},
"additionalFields": {}
},
{
"type": "image",
"value": {},
"marker": "image",
"position": 3,
"listTitles": [],
"validators": {},
"initialValue": null,
"localizeInfos": {
"title": "Image"
},
"additionalFields": {}
}
]
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 { AttributesSets } = defineOneEntry(PROJECT_URL, {
token: APP_TOKEN,
});
// 3. Get attribute schema by marker with [AttributesSets.getAttributesByMarker()](/docs/attribute-sets/getAttributeSetByMarker)
const attributes = await AttributesSets.getAttributesByMarker(
'product',
'en_US',
);
console.log('Attributes: ', attributes);