Skip to main content

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, and listTitles

Prerequisites:

  • A valid PROJECT_URL and APP_TOKEN for 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. With isShell: false it throws, and you handle errors with try/catch. See Errors.
  • Returns the attribute schema, not the values stored in entities.
  • value holds no entity data. It is null for most attribute types. A timeInterval attribute can return its schedule as an array of intervals (possibly empty) or null. To read actual values, use Products.getProducts(), Pages.getPageByUrl(), and similar methods.
  • Use listTitles to build filter options for list and radioButton attributes.

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);