Get attributes by marker
Fetches the attribute schema of an attribute set by its marker.
What this example does:
- Connects to the OneEntry API
- Retrieves the attribute schema for a named attribute set
- Reads attribute metadata:
marker,type,localizeInfos.title,validators, andlistTitles
Prerequisites:
- A valid
PROJECT_URLandAPP_TOKENfor the OneEntry API - An attribute set configured in OneEntry with a known marker (e.g., "product")
Notes:
- By default (
isShell: true) the SDK returns an error object instead of throwing, so check the result, e.g.'statusCode' in result. WithisShell: falseit throws, and you handle errors with try/catch. See Errors. - Returns the attribute schema, not the values stored in entities.
valueholds no entity data. It isnullfor most attribute types. AtimeIntervalattribute can return its schedule as an array of intervals (possibly empty) ornull. To read actual values, useProducts.getProducts(),Pages.getPageByUrl(), and similar methods.- Use
listTitlesto build filter options forlistandradioButtonattributes.
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';
const PROJECT_URL = 'https://your-project.oneentry.cloud';
const APP_TOKEN = 'your-app-token';
2. Create an API client with defineOneEntry()
const { AttributesSets } = defineOneEntry(PROJECT_URL, {
token: APP_TOKEN,
});
3. Get attribute schema by marker with AttributesSets.getAttributesByMarker()
const attributes = await AttributesSets.getAttributesByMarker(
'product',
'en_US',
);
if ('statusCode' in attributes) {
throw new Error(attributes.message);
}
console.log('Attributes: ', attributes);
Result:
[
{
"type": "real",
"value": null,
"marker": "price",
"position": 1,
"listTitles": [],
"validators": {
"requiredValidator": {
"strict": true
}
},
"multiselect": false,
"initialValue": null,
"localizeInfos": {
"title": "Price"
},
"additionalFields": {}
},
{
"type": "string",
"value": null,
"marker": "currency",
"position": 2,
"listTitles": [],
"validators": {
"defaultValueValidator": {
"fieldDefaultValue": "USD",
"fieldDefaultValue2": ""
}
},
"multiselect": false,
"initialValue": null,
"localizeInfos": {
"title": "Currency"
},
"additionalFields": {}
},
{
"type": "image",
"value": null,
"marker": "image",
"position": 3,
"listTitles": [],
"validators": {},
"multiselect": false,
"initialValue": null,
"localizeInfos": {
"title": "Image"
},
"additionalFields": {}
}
]
Final example
// 1. Import defineOneEntry and define PROJECT_URL and APP_TOKEN
import { defineOneEntry } from 'oneentry';
const PROJECT_URL = 'https://your-project.oneentry.cloud';
const APP_TOKEN = 'your-app-token';
// 2. Create an API client with defineOneEntry()
const { AttributesSets } = defineOneEntry(PROJECT_URL, {
token: APP_TOKEN,
});
// 3. Get attribute schema by marker with AttributesSets.getAttributesByMarker()
const attributes = await AttributesSets.getAttributesByMarker(
'product',
'en_US',
);
if ('statusCode' in attributes) {
throw new Error(attributes.message);
}
console.log('Attributes: ', attributes);