Crownpeak
  • Product Discovery Developer Guide
  • 🛒Item catalog management
    • What is the Items API?
    • How to work with Items
      • Item Schema
        • Attributes
        • Nested Item Schemas
        • Using the Item Schema API
        • DefaultLocale API
        • Onboarding on/migrating to Fredhopper
        • List of Reserved Attributes
      • Category Tree
        • Using the Category Tree API
        • Onboarding on XO
      • Item Catalog
        • Using the Catalog API
      • Items
        • Using the streaming Items API
        • Using the batch Items API
    • Step by Step guide
      • Step by step guide for Fredhopper customers
    • Feedback
      • Using the Feedback API
    • Authorization to APIs
    • Troubleshooting API errors
  • 🎯XO Recommendations
    • Introduction
    • Using the Recommendations API
    • Setting up the Chrome extension
    • Micro-segmentation
    • XO Legacy APIs
  • 🔎XO Search
    • Introduction
    • Getting started
    • API Reference
      • Search API
      • Autocomplete API (Beta)
      • Product Suggest API
    • API Parameters
      • Search
      • Pagination
      • Faceting
      • Sorting
      • Grouping
      • Filtering
      • Disable features
      • Response mask
      • Context
    • Configuration limitation
  • 🧪A/B testing
    • Fredhopper A/B testing
      • Integration steps for a non-caching solution
      • Integration steps for a caching solution
        • Java SDK Integration
          • Setup
          • Retrieve running A/B tests - Java SDK
          • Filter and request variant - Java SDK
          • Extending the SDK
        • Manual A/B tests integration
          • Retrieve running A/B tests
          • Filter out irrelevant A/B tests
          • Assign variants to user
          • Request variant for page
        • Limitations and Best Practices
  • 📚Resources
    • Glossary
    • Best Practices
      • Tracker Best Practices
      • Items API Best Practices
      • Fredhopper Data Configuration Best Practices
      • Fredhopper Query Response Best Practices
      • Fredhopper Merchandising Studio Best Practices
    • Privacy Notice
  • Archived Pages
    • FHR Tracking plan
    • XO Tracking plan
    • The Tracking API and JS Library
      • What to Track
        • Generic Actions
          • View
          • Click
          • Add to Cart
          • Remove from Cart
          • Purchase
        • Custom Actions
      • Initializing the JavaScript Library
      • REST API Technical Documentation
Powered by GitBook
On this page
  • Parameters
  • customResponeMask
  • Response
  • Usage example
  1. XO Search
  2. API Parameters

Response mask

Select only the fields you want from the response's items

Parameters

The customResponseMask parameter allows selecting only the attributes you want from the items in the response.

Name

Type

Is Required ?

Default value

customResponseMask

string

✖

empty string

customResponeMask

The items attributes will be filtered based on the response mask. The syntax is:

  • a,b,c : comma-separated list will select multiple fields

  • a.b.c : path will select a field from its parent

  • a(b,c): sub-selection will select many fields from a parent

  • a.*.c : the star * wildcard will select all items in a field

Example

  • id, product(title, price) will return only the id, the title and the price of the items

Notes

  • If empty, or omitted, all fields will be returned for the items

Response

Usage example

  • Only returns the id, the product title and price

NodeJS / NPM example

import { search } from '@attraqt/search';

const query = 'T-shirt';

search.init({ token: SEARCH_API_TOKEN });

const response = await search.query(query, {
  customResponseMask: 'id, product(title, price)'
});

console.log(response);

HTML example

<script type="text/javascript">
    xo.init({
        search: {
            token: SEARCH_API_TOKEN
        }
    });

    xo.search.query('T-Shirt', {
        customResponseMask: 'id, product(title, price)'
    }).then((response) => {
        console.log(response);
    });
</script>

HTTP example

POST https://api-eu.attraqt.io/search HTTP/1.1
Content-Type: application/json; charset=UTF-8

{
  "token": "SEARCH_API_TOKEN",
  "query": "T-Shirt",
  "options": {
    "customResponseMask": "id, product(title, price)"
  }
}

curl example

curl -d "{\"token\":\"${SEARCH_API_TOKEN}\", \"query\":\"T-Shirt\", \"options\":{\"customResponseMask\": \"id, product(title, price)\"}}" \
     -H "Content-Type: application/json; charset=UTF-8"                                                                                   \
     -X POST "https://api-eu.attraqt.io/search"

JavaScript example

const response = await fetch('https://api-eu.attraqt.io/search', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json; charset=UTF-8'
  },
  body: JSON.stringify({
    token: SEARCH_API_TOKEN,
    query: 'T-Shirt',
    options: {
      customResponseMask: 'id, product(title, price)'
    }
  })
});

if (response.ok) {
  console.log(await response.json());
}

HTTP example

GET https://api-eu.attraqt.io/search/:token?encoded=:encodedParams HTTP/1.1

curl example

curl "https://api-eu.attraqt.io/search/${SEARCH_API_TOKEN}?encoded=%7B%22query%22%3A%22T-Shirt%22%2C%22options%22%3A%7B%22customResponseMask%22%3A%22id%2C%20product%28title%2C%20price%29%22%7D%7D"

JavaScript example

const token = SEARCH_API_TOKEN;
const params = encodeURIComponent(JSON.stringify({
  query: 'T-shirt',
  options: {
    customResponseMask: 'id, product(title, price)'
  }  
}));

const response = await fetch(
  `https://api-eu.attraqt.io/search/${token}?encoded=${params}`
);

if (response.ok) {
  console.log(await response.json());
}
PreviousDisable featuresNextContext

Last updated 3 years ago

All responses from XO Search uses the same format. Check page for a more detailed description of this format.

🔎
API Reference
API Reference