Headless Query API JSON response

Website personalisation: Headless API integration

ITMAP: Id - Titles - Media - Abstracts - Properties

Ometria's onsite feature uses the ITMAP pattern in several areas.

Most objects are based on this pattern and by understanding this pattern you will understand the Query API JSON response.

[
 {
   "id": "186917",
   "titles": {
     "default": "Floral Dress",
     "alt_title": "Summer Dress"
   },
   "media": {
     "default": {
       "src": "https://mysite.com/images/floral-dress.jpg",
       "width": 400,
       "height": 400
     },
     "alt1": {
       "src": "https://mysite.com/images/floral-dress-alt1.jpg",
       "width": 550,
       "height": 550
     }
   },
   "abstracts": {
     "default": "<p>Light floral summer dress</p>",
     "washing_instructions": "<p>Machine washable and tumble dryer ready</p>"
   },
   "properties": {
     "washable": true,
     "extra_info": "stain resistant",
     "warranty": "1 year"
   }
 },
 {
   "id": "207893",
   "titles": {
     "default": "Padded Puffer Jacket",
     "alt_title": "Winter Coat"
   },
   "properties": {
     "washable": false,
     "water_resistant": false,
     "season": "winter"
   }
 },
 {
   "id": "118751",
   "abstracts": {
     "default": "Full Zip Woven Hoodie",
     "alt": "Sports top for training hard"
   }
 }
]

Parameter

Required?

Type

Description

id

Required

String or number

A string or number containing the unique identifier for an object.

In nearly all cases the id field will be present.

The exception is for special cases like facets and filters where sometimes an object can have no id.

titles

Optional

Object

An object containing a collection of titles (key-value pairs).

The titles object can contain multiple titles. The main title is labelled "default".

If an item has no titles then the titles object is omitted from the response.

media

Optional

Object

An object containing a collection of abstracts (key-object pairs).

The media object can contain multiple objects.

The main object is labelled "default".

If an item has no items then the media object is omitted from the response.

Each object within the key-object pairs can contain multiple key-value pairs, but by convention there is normally an "src" key-value pair.

abstacts

Optional

Object

An object containing a collection of abstracts (key-value pairs).

The abstracts object can contain multiple abstracts. By convention the main abstract is labelled "default".

If an item has no abstracts then the abstracts object will be omitted from the response.

abstracts typically contain HTML.

properties

Optional

Object

An object containing a collection of properties (key-value pairs).

The values can be of any of the simple (expanded) JSON data types:

  • Number
  • String
  • Boolean
  • Date If an item has no titles then the properties object will be omitted from the response.DITMAP: Where products are listed, ITMAP is used. On detail pages a Description field is also added.

descriptions

Optional

Object

An object containing a collection of descriptions (key-value pairs).

The descriptions object can contain multiple descriptions.

The main description is labelled "default".
If an item has no descriptions then the descriptions object is omitted from the response.

descriptions typically contain HTML.

NULL values

Ometria omits null values from the response.

This means you need to perform null checks when parsing the JSON response.

Because data is variable, it is also important to consider that most fields should be considered optional in the response.

{
   "elements": {
       "category": {
           "products": {
               "results": [
                   {
                       "item": {
                           "id": "186917",
                           "titles": {
                               "default": "Floral Dress",
                               "alt_title": "Summer Dress"
                           },
                           "media": {
                               "default": {
                                   "src": "https://mysite.com/images/floral-dress.jpg",
                                   "width": 400,
                                   "height": 400
                               }
                           },
                           "pricing": {
                               "price": 25.99,
                               "was": 29.99
                           }
                       }
                   },
                   {
                       "meta": {
                           "element_design_set": {
                               "id": "dbd2f7cd3007441a85e6ac5024e6bcaf",
                               "name": "Best Sellers",
                               "color": "#336699"
                           }
                       },
                       "item": {
                           "id": "207893",
                           "titles": {
                               "default": "Padded Puffer Jacket",
                               "alt_title": "Winter Coat"
                           }
                       }
                   },
                   {
                       "item": {
                           "id": "118751",
                           "abstracts": {
                               "default": "Full Zip Woven Hoodie",
                               "alt": "Sports top for training hard"
                           },
                           "pricing": {
                               "price": 17.50
                           }
                       }
                   }
               ]
           }
       }
   }
}
const json = await getGrapheneHCResponse();
json.elements.category.products.results.forEach(record => {
   const   item        = record.item;
   const   id          = item.id;
   const   title       = item.titles?.default || "n/a";
   const   alt         = item.titles?.alt_title || "n/a";
   const   abstr       = item.abstracts?.default || "n/a";
   const   img         = item.media?.default?.src || "https://mysite.com/images/not-found.jpg";
   const   price       = item.pricing?.price || "n/a";
   const   was         = item.pricing?.was || "n/a";
   console.log(`[id]: ${id}\n[title]: ${title}\n[alt]: ${alt}\n[abstr]: ${abstr}\n[image]: ${img}\n[price]: ${price}\n[was]: ${was}`);
});
// would result in the following output
/*
[id]: 186917
[title]: Floral Dress
[alt]: Summer Dress
[abstr]: n/a
[image]: https://mysite.com/images/floral-dress.jpg
[price]: 25.99
[was]: 29.99
[id]: 207893
[title]: Padded Puffer Jacket
[alt]: Winter Coat
[abstr]: n/a
[image]: https://mysite.com/images/not-found.jpg
[price]: n/a
[was]: n/a
[id]: 118751
[title]: n/a
[alt]: n/a
[abstr]: Full Zip Woven Hoodie
[image]: https://mysite.com/images/not-found.jpg
[price]: 17.5
[was]: n/a
*/

Headless JSON response reference

Here's a full description of the JSON response schema.

Structure

This is a quick map of the response structure:

request_id
response_id
user
   /* properties */
header
   /* properties */
elements
   "category"
       performance
           /* properties */
       products
           meta
               /* properties */
           results
               meta
                   /* properties (including ITMAP) */
               item
                   /* properties (including ITMAP) */
           filters
               /* properties */
               all
                   items
                       /* properties (including ITMAP) */
           facets
               items
                   /* properties (including ITMAP) */

Example

Here is an example of a response for a category page query which contains three page elements.

Query:

POST "https://{{domainkey}}.store-{{locationkey}}.ometria.services/api/query"
{
   "elements"      : ["category", "cat_1", "cat_2"],
   "user": {
       "uid"           : "ebf3175817b0423eac68a03c68a9be5f",
       "sid"           : "961c660991a547298af8b31f431a66b0"
   },
   "context": {
       "category"      : "dresses",
       "page_url"      : "/dresses/",
       "user_agent"    : "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:15.0) Gecko/20100101 Firefox/15.0.1"
   }
}

Response:

-{

   "request_id": "d6f5fac4c7cd43518342729c5e502ffb",

   "response_id": "8f0e2f04dbf44f24be80c60a5cc57625",

   "user": +{...},

   "header": +{...},

   "elements": +{...}

}

Parameters

Parameter

Required?

Type

Description

request_id

Optional

String or number

A string or number containing a unique identifier.

The API will return this value back with the response.

response_id

Required

String

A string containing a unique identifier.

This is a randomly generated unique identifier for the individual request/response.

user

Required

Object

An object containing key information about the current user.

uid

Required

String

The unique identifier for the visitor/customer.

sid

Required

String

A string containing the session ID.

header

Required

Object

A series of informational variables.

status

Required

Number

A number containing the status of the request.

Typically 200 for a successful request and 500 for an error.

language

Required

String

A string containing the language used during the processing of the query.

If a language was sent in the request this should match that value.

currency

Required

String

A string containing the currency used during the processing of the query.

If a currency was sent in the request this should match that value.

elements

Required

Array

An array containing a list of elements.

Each element is a container for a set of products.

element

Required

Object

elements.{{element}}

An object containing the results for the individual element query.

element is an ITMAP object.

product

Required

Object

elements.{{element}}.products

An object containing all aspects of the product search for this element.

meta

Required

Object

elements.{{element}}.products.meta

An object containing key-value pairs related to this element, including:

  • click_codes
  • page_size
  • page_count
  • …and various other pieces of meta information.

results

Required

Array

elements.{{element}}.products.results

An array containing a list of product results.

meta

Optional

Object

elements.{{element}}.products.results.meta

An object containing key-value pairs related to this product.

item

Required

Object

elements.{{element}}.products.results.item

An object containing the product details.
item is an ITMAP object.

sku

Optional

String

elements.{{element}}.products.results.item.sku

A string representing the product sku.

url

Optional

String

elements.{{element}}.products.results.item.url

A string representation for the product url.

pricing

Optional

Object

elements.{{element}}.products.results.item.pricing

An object containing price information.

price

Optional

Number

elements.{{element}}.products.results.item.pricing.price

A number representation for the product price.

was

Optional

Number

elements.{{element}}.products.results.item.pricing.was

A number representation for the product was price.

rrp

Optional

Number

elements.{{element}}.products.results.item.pricing.rrp

A number representation for the product recommended retail price.